bugDotGNU Portable.NET - Bugs: bug #2052, Activator.CreateInstance() uses...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #2052: Activator.CreateInstance() uses incorrect default binding flags

Submitted by:  Marcus Urban <mathpup>
Submitted on:  Thu 26 Dec 2002 06:18:50 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Thu 26 Dec 2002 07:44:53 AM UTC, comment #1:

The fix is to remove BindingFlags.NonPublic from the argument lists of several overloaded constructors because by default only public constructors should be sought.

I'm attaching a patch file.

Marcus Urban <mathpup>
Thu 26 Dec 2002 06:18:50 AM UTC, original submission:

In the overloaded versions of CreateInstance() that do not accept a BindingFlags argument, the binding flags should be set to look only for public instance constructors. In the current implementation, CreateInstance() looks for both public and non-public methods.

In the attached program, the class libs should throw a System.MissingMethodException because the applicable constructor is not public and no binding flags were specified. Instead, the libs invoke the constructor and the program prints the value "4".

Marcus Urban <mathpup>

 

Attached Files
file #210:  Activator.cs-patch added by mathpup (2KiB - text/x-diff - Patch)
file #209:  activator2.cs added by mathpup (388B - text/x-csharp - Test case)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 2 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Thu 26 Dec 2002 08:12:49 AM UTCt3rmin4t0rStatusNone=>(Error - Not Found)
  Open/ClosedOpen=>(Error - Not Found)

Back to the top


Powered by Savane 3.1-cleanup1