Calling an internal constructor

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I know I can use reflection to call internal, protected, and private methods
in a class, but I need to instantiate an object that is public but has an
internal constructor (The CurrencyManager class).

Is there a way to do this with reflection?

I'm so mad at MS about the CurrencyManager design it makes me want to
scream. It's been causing me headaches for months.

All of this would be easily fixable if I could create my own CurrencyManager
derived from BindingManagerBase, and though the documentation has a "Note to
inheritors" section, BindingManagerBase actually has internal virtual
methods, so there's no way to derive from it outside of S.W.F. ARGH.

Pete


.



Relevant Pages

  • Re: Calling an internal constructor
    ... there is nothing you can do to call this constructor from ... your constructor in code (even through reflection) so that your class can ... > internal constructor (The CurrencyManager class). ... > derived from BindingManagerBase, and though the documentation has a "Note ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Calling an internal constructor
    ... The CurrencyManager one? ... reflection, but the correct fix would be for them to simply provide a method ... I didn't realize that invoking the constructor would create an object. ... BindingManagerBase actually has internal virtual ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: unit testing private methods
    ... .I think this uses reflection to access private methods ... depend on and establish program invariants. ... complicated reflection fooferol unnecessary for unit-test purposes. ...
    (comp.lang.java.programmer)
  • Re: JUnit FAQ suggests private methods bad design?
    ... I don't know if reflection in Java has this ... The easiest method I've found to test private methods is to make the ... A static inner class has access to all ... Another benefit to using inner classes is that they force the developer ...
    (comp.object)
  • Re: NUnit Test
    ... Not an easy way, look at reflection and you can get hold of private methods, ... but a bit of extra work to get there. ... I'm new to NUnit. ...
    (microsoft.public.dotnet.languages.csharp)