473,499 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Method not found??

I've an exe that creates an object with reflection using Createinstance. All
ok.
Then I call method in this object, that returns a user-defined control. This
code is executed.
I've very strange problem in the user-defined control constructor. Some code
is executed. This calls mybase.new, initializecomponent, and sets some
property on contained panels. Then the constructor calls an internal sub
(public or private is the same, I've tried either). This sub may create some
other objects, but this is not the problem. The problem is that when I call
the sub from the constructor, I get this strange error:

Method not found: Void
MyNameSpace.PanelPreview..ctor(MyNameSpace.Display Area, Byte).

The sub I'm trying to call is
Private Sub BindPageToPreview(ByVal page As DisplayPage)

The constructor is:

Public Sub New(ByRef display As myobjecttype)

MyBase.New(DirectCast(display, DisplayHardwareDevice))

InitializeComponent()

' please note that this panelPreview is not a normal windows panel, not
a panelpreview type object. Is it created yb designer, so it is instantiated
by initializecomponent

panelPreview.Width = CPU.Width * _scaleFactor

panelPreview.Height = (CPU.Height + display.Page(0).Area(0).Height) *
_scaleFactor

BindPageToPreview(display.Page(0))

End Sub

The sub is defined in the same -vb file as

Private Sub BindPageToPreview(ByVal page As DisplayPage)

[cut]

end sub

This same code, if called by a simple test program, works well.

What can I do?

thanks


Nov 20 '05 #1
4 5423
* "Trapulo" <no**********@qui.it> scripsit:
I've an exe that creates an object with reflection using Createinstance. All
ok.
Then I call method in this object, that returns a user-defined control. This
code is executed.
I've very strange problem in the user-defined control constructor. Some code
is executed. This calls mybase.new, initializecomponent, and sets some
property on contained panels. Then the constructor calls an internal sub
(public or private is the same, I've tried either). This sub may create some
other objects, but this is not the problem. The problem is that when I call
the sub from the constructor, I get this strange error:

Method not found: Void
MyNameSpace.PanelPreview..ctor(MyNameSpace.Display Area, Byte).

The sub I'm trying to call is
Private Sub BindPageToPreview(ByVal page As DisplayPage)

The constructor is:

Public Sub New(ByRef display As myobjecttype)


Is that the ctor of 'PanelView'? Why do you pass 'display' 'ByRef'?
The signature of this ctor is different from the ctor you try to call.

The designer will always call the parameterless ctor to instantiate
classes.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2h************@uni-berlin.de...
* "Trapulo" <no**********@qui.it> scripsit:
I've an exe that creates an object with reflection using Createinstance. All ok.
Then I call method in this object, that returns a user-defined control. This code is executed.
I've very strange problem in the user-defined control constructor. Some code is executed. This calls mybase.new, initializecomponent, and sets some
property on contained panels. Then the constructor calls an internal sub
(public or private is the same, I've tried either). This sub may create some other objects, but this is not the problem. The problem is that when I call the sub from the constructor, I get this strange error:

Method not found: Void
MyNameSpace.PanelPreview..ctor(MyNameSpace.Display Area, Byte).

The sub I'm trying to call is
Private Sub BindPageToPreview(ByVal page As DisplayPage)

The constructor is:

Public Sub New(ByRef display As myobjecttype)
Is that the ctor of 'PanelView'? Why do you pass 'display' 'ByRef'?
The signature of this ctor is different from the ctor you try to call.


No, the sequence is:
1- the client calls constructor of "display" object
2 - on the created object the client calls a method (getEmulator)
3 - this method create a new emulator object (the one with this sub new) and
passes a reference to itself: return new emulator(me)...
4 - this constructor (of emulator) fails when it calls the internal sub. All
other construcotor's code runs.
The designer will always call the parameterless ctor to instantiate
classes.


I know this, but the problem is at runtime and only with the client that
creates the first object with reflection's createInstance... With a simple
test client it works.

thanks
Nov 20 '05 #3
Hi Trapulo,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you have an test Application which
will use an object.
If the object is created by CreateInstance(i.e. by reflection), there will
be an exception thrown when the object is trying to new an user control.
But if the object is created by adding reference to the object assembly and
then New the object directly, the problem will not occur.
That is to say, all the other code is same exception the protion how the
object is created in the test Applicaion, and all the other code did not
use reflection to create object.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

One possible cause is that you did not use the full qulified name to
createinstance, so that the reflection did not bind to the correct version
of assembly. So how do you use reflection to CreateInstance?

You may try to strongname the object assembly and use the Full Qualified
Name of the Assembly to create the object. You may follow the sample in the
link below.
Activator.CreateInstance Method
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemactivatorclasscreateinstancetopic.asp

Please apply my suggestion above and let me know if it helps resolve your
problem.
If this does not resolved the problem, can you build a reproduce sample as
simple as possible and send to by removing the online from my email
address? So that we can do further troubleshooting.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #4
I solved.

You suggested the right way where to search the problem.
The problem was that an assembly used by the object created by reflection
was in wrong version in production application's domain. So when the created
object created some objects from this assembly, it failed.
Now it works.

Thanks for your assistance.
""Peter Huang"" <v-******@online.microsoft.com> wrote in message
news:ok**************@cpmsftngxa10.phx.gbl...
Hi Trapulo,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you have an test Application which will use an object.
If the object is created by CreateInstance(i.e. by reflection), there will
be an exception thrown when the object is trying to new an user control.
But if the object is created by adding reference to the object assembly and then New the object directly, the problem will not occur.
That is to say, all the other code is same exception the protion how the
object is created in the test Applicaion, and all the other code did not
use reflection to create object.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

One possible cause is that you did not use the full qulified name to
createinstance, so that the reflection did not bind to the correct version
of assembly. So how do you use reflection to CreateInstance?

You may try to strongname the object assembly and use the Full Qualified
Name of the Assembly to create the object. You may follow the sample in the link below.
Activator.CreateInstance Method
http://msdn.microsoft.com/library/de...us/cpref/html/ frlrfsystemactivatorclasscreateinstancetopic.asp

Please apply my suggestion above and let me know if it helps resolve your
problem.
If this does not resolved the problem, can you build a reproduce sample as
simple as possible and send to by removing the online from my email
address? So that we can do further troubleshooting.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2698
by: Phil Powell | last post by:
/*-------------------------------------------------------------------------------------------------------------------------------- Parameters: $formField1: The name of the first array $formField2:...
4
7061
by: Ruud de Jong | last post by:
The question I have is: how safe / future proof / portable is the use of the __subclasses__ method that exists for new-style classes? Background: I thought I had found an easy-to-understand...
0
1608
by: scorpion | last post by:
This question is more XML Security (and specifically, on the Apache XML security implementation). When I sign or open signed XML document, I see the following warning: .... WARNING: Found an...
28
5168
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
5
3392
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
18
4705
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
2
7152
by: sianan | last post by:
I am having a problem doing the following in generics. I have two list of a custom item type. I need to iterate through the first list and match each item against another list to see if there is...
4
1707
by: ddtl | last post by:
Hello everybody. Consider the following code: class A(object): def met(self): print 'A.met' class B(A): def met(self):
1
3107
by: Jan | last post by:
When I use Type.InvokeMember from my remoting server object I get a MissingMethodException: "Method '<namenot found.". My code works when the code is called normally, but not when executed from...
0
2322
by: =?Utf-8?B?TW9ydGVuIFdlbm5ldmlrIFtDIyBNVlBd?= | last post by:
"Anders Borum" wrote: Hi Anders, I'm afraid the GetMethod() does not currently support filtering on generic parameters so you will have to loop through the existing methods using...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
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
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
295
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.