473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

System.MissingMethodException when calling Private constructor

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
4 5184
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: System.Reflection Activator | last post by:
************************************** //Load the Assembly Assembly a = Assembly.LoadFrom(sAssembly); //Get Types so we can Identify the Interface. Type mytypes = a.GetTypes(); BindingFlags...
0
by: Giovane Calabrese | last post by:
ok. im try to make a multilanguage system based on that tutorial : http://www.123aspx.com/redir.aspx?res=29112 in my aspx pages all text are in labels , and i want to take the name labels...
0
by: Gos | last post by:
I have a form object (I pass form object into variable obj and do late binding) to be passed as an argument. Dim Prop As String Dim Properties As Type Private Sub LoadObjectSettings(ByRef...
10
by: One Handed Man [ OHM ] | last post by:
If this is duplicated, I'm sorry because I cant find the original post I made today Anyway . . Now its my turn to ask a question I want to develop an app which will run in the system tray....
0
by: Harry F. Harrison | last post by:
Hi folks, I'm getting the following error message using the System.Activator.CreateInstance shared method: A first chance exception of type 'System.MissingMethodException' occurred in...
1
by: logdenav | last post by:
Hello I'm testing the performance of the System.Timers.Timer class. I created a small program that create 100 User objects. Each USer object create a MyTimer object. The constructor of the User...
7
by: Fir5tSight | last post by:
Hi All, I used the following code in C#: using System.Drawing; //blah blah blah Bitmap bmp = new Bitmap();
0
by: Alan Pretre | last post by:
Our application has received this exception. It is a Win32 service that runs 24/7. The app has been in the field at various sites for about 3 yrs and we have never seen this error until now. ...
3
by: Dmitry | last post by:
I am trying to figure out how to pass set of credentials to System.IO Challenge is: App is running under one set of credentials, but via GUI user have a chance to enter another set. I would like...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.