By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,725 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,725 IT Pros & Developers. It's quick & easy.

System.MissingMethodException when calling Private constructor

P: n/a
Hi,

Can anyone advise how to call a private constructor using reflection? I
currently get the above error which is rectified by changing the New() to
Public from Friend but I ideally wish to leave it as Friend to prevent it
being created outside of this project.

Thanks in advance

Rob

Jan 17 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I mean calling a Friend constructor from another class within the same
project via reflection. Apologies for any confusion with the original post.
Hi,

Can anyone advise how to call a private constructor using reflection? I
currently get the above error which is rectified by changing the New() to
Public from Friend but I ideally wish to leave it as Friend to prevent it
being created outside of this project.

Thanks in advance

Rob
Jan 17 '08 #2

P: n/a
hi Rob,

Might help if you show the code you are using. If the type is in the same
assembly, then Activator.CreateInstance(GetType(foo), true) will work


"Rob Blackmore" <ro*@robblackmore.comwrote in message
news:eZ**************@TK2MSFTNGP02.phx.gbl...
>I mean calling a Friend constructor from another class within the same
project via reflection. Apologies for any confusion with the original
post.
>Hi,

Can anyone advise how to call a private constructor using reflection? I
currently get the above error which is rectified by changing the New() to
Public from Friend but I ideally wish to leave it as Friend to prevent it
being created outside of this project.

Thanks in advance

Rob
Jan 17 '08 #3

P: n/a
Hi,

I am using GetType.InvokeMember with the invokeAttr argument of
Reflection.BindingFlags.CreateInstance and both classes are in the same VB
2008 project.

It works fine if I change the New() to Public but not whilst it is friend

Thank you

Rob

"Bill McCarthy" <Bi**@NOSPAM.comwrote in message
news:C2**********************************@microsof t.com...
hi Rob,

Might help if you show the code you are using. If the type is in the same
assembly, then Activator.CreateInstance(GetType(foo), true) will work


"Rob Blackmore" <ro*@robblackmore.comwrote in message
news:eZ**************@TK2MSFTNGP02.phx.gbl...
>>I mean calling a Friend constructor from another class within the same
project via reflection. Apologies for any confusion with the original
post.
>>Hi,

Can anyone advise how to call a private constructor using reflection? I
currently get the above error which is rectified by changing the New()
to Public from Friend but I ideally wish to leave it as Friend to
prevent it being created outside of this project.

Thanks in advance

Rob
Jan 18 '08 #4

P: n/a
Hi Rob,

As I suggested earlier, you should use Activator.CreateInstance(type,True).
InvokeMember ignores other flags if the CreateInstance flag is specified.

"Rob Blackmore" <ro*@robblackmore.comwrote in message
news:AB**********************************@microsof t.com...
Hi,

I am using GetType.InvokeMember with the invokeAttr argument of
Reflection.BindingFlags.CreateInstance and both classes are in the same VB
2008 project.

It works fine if I change the New() to Public but not whilst it is friend

Thank you

Rob

"Bill McCarthy" <Bi**@NOSPAM.comwrote in message
news:C2**********************************@microsof t.com...
>hi Rob,

Might help if you show the code you are using. If the type is in the
same assembly, then Activator.CreateInstance(GetType(foo), true) will
work


"Rob Blackmore" <ro*@robblackmore.comwrote in message
news:eZ**************@TK2MSFTNGP02.phx.gbl...
>>>I mean calling a Friend constructor from another class within the same
project via reflection. Apologies for any confusion with the original
post.

Hi,

Can anyone advise how to call a private constructor using reflection?
I currently get the above error which is rectified by changing the
New() to Public from Friend but I ideally wish to leave it as Friend to
prevent it being created outside of this project.

Thanks in advance

Rob

Jan 19 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.