473,800 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with GetType().Invok eMember

Hi,

I have a object which is created by using the Assembly.Create Instance
method.

Assembly testAss = Assembly.LoadWi thPartialName(" Test");
object obj = testAss.CreateI nstance("Sample 1.SampleTest");
//This obj is the instance of SampleTest Class

Upto this the cod is working fine.

When i try to invoke one method of the SampleTest Class with obj its
giving the result object Undefined Value.

This is my code.
object[] Parameters = new object[2];
Parameters[0] = methodName;//It is string
Parameters[1] = clientReqAL;//clientReqAL is the ArrayList Containing
Two Values(string).
if(wrapperInst! =null)
{
object result = obj.GetType().I nvokeMember("Te stMethod",
BindingFlags.In vokeMethod,null ,obj,Parameters );
}

How can i solve this problem .If anybody knows the solution let me
know.

Thanks,
Vinoth

Nov 17 '05 #1
2 8202
vi****@gsdindia .com wrote:
object result = obj.GetType().I nvokeMember("Te stMethod",
BindingFlags.In vokeMethod,null ,obj,Parameters );


You'll have to make this

BindingFlags.In vokeMethod | BindingFlags.In stance | BindingFlags.Pu blic

assuming your method is an instance method (which I'm quite sure of from
your description) and it's public (otherwise, replace the Public flag by
NonPublic).

Hope this helps!
Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog
Nov 17 '05 #2
vi****@gsdindia .com wrote:
object result = obj.GetType().I nvokeMember("Te stMethod",
BindingFlags.In vokeMethod,null ,obj,Parameters );


You'll have to make this

BindingFlags.In vokeMethod | BindingFlags.In stance | BindingFlags.Pu blic

assuming your method is an instance method (which I'm quite sure of from
your description) and it's public (otherwise, replace the Public flag by
NonPublic).

Hope this helps!
Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog
Nov 17 '05 #3

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

Similar topics

6
2459
by: Diego Valencia | last post by:
The attach error was generate when I tried to use invoke method "setpassword" this is mi code objeto.Invoke("SetPassword", new object {contraseña}); The error is "The filename, directory name, or volume label syntax is incorrect" Exception Detail : System.IO.FileNotFoundException:The filename, directory
1
1489
by: Matthias Pieroth | last post by:
Hi NG, I have an OCX (VC++ 6.0) that fires some events. I have to use it on a form an have to catch the events in event-handlers in another form (MDI-Child). BUT: I have to create the other Form by Reflection, it is in a ClassLibrary that has to be loaded dynamically. I first tried it without the ClassLibrary and it works. I give the OCX to the Subform, declare my Eventhandlers there and bind the ocx to these eventhandlers, no problem,...
0
324
by: vinoth | last post by:
Hi, I have a object which is created by using the Assembly.CreateInstance method. Assembly testAss = Assembly.LoadWithPartialName("Test"); object obj = testAss.CreateInstance("Sample1.SampleTest"); //This obj is the instance of SampleTest Class Upto this the cod is working fine.
0
1313
by: Pat Ireland | last post by:
I continue to investigate issues with making explicit InvokeMember calls (necessary when dynamically loading classes). My quest lets me use a simple class to invoke another class's member method by normal means and by using the InvokeMember. By examining the underlying il code with ildasm, when attempting to pass by reference, the il code generates a box command so that a pointer to the actual data is passed. This is clearly seen with...
1
2401
by: Raveendra M | last post by:
Hi! I am working with ASP.NET application. In my page I am creating one Application Domain and in that domain I am calling my DLL. Using the methods of the dll. And unloading the Application Domain. Till this point it is working fine. My problem is, while web page is open, than I am modifying the dll, and rebuilding. Then it is giving error: "The file 'MyClass.dll' cannot be copied to the run directory. The process cannot access the...
7
6767
by: Denis Samoilov | last post by:
We have a namespace N which includes enumeration ENUM1 and a class C with property C.Enum1, e.g. namespace N { public enum ENUM1{}; public class C { public ENUM1 Enum1 { get{} set{}
1
1295
by: Udi | last post by:
Hi All, I have a function that I need to call on reflection that has an out parameter (maybe more than one). My problem is that I'm not receiving the out values. The following code works fine on VS2003, but not on 2005: ArrayList myArgs = new ArrayList(); Int outVal;
2
2982
by: =?Utf-8?B?UmVuYXVkIExhbmdpcw==?= | last post by:
Hello, I have an asp.net web page (say page.aspx) which derives from a custom base page object (CustomPage : BasePage : System.Web.UI.Page) Which has a method called DoSomething(params). My web page contains a UserControl (say Control.ascx). In the control class, i want to call the DoSomething method. I cannot use type cast since in fact the base class Page structure is a little more complex (see bottom of post). Hence i cannot do:
1
1874
by: tommyk | last post by:
I am writing a small program that reads a text file filled with a large number of IP addresses and attempts to add them to IIS so that they will be blocked. For some reason, about one in every five or six ip addresses that I attempt to add to IIS causes an System.Reflection.TargetInvocationException to be thrown. Here is the code that adds the addresses: static void SetIPSecurityProperty(string metabasePath, string member, string item)...
0
1802
by: Jason Huang | last post by:
Hi, In my C# windows form project, I was trying to call a Excel macro. However, the GetType().InvokeMember was confusing me. Would some give me some easy sample to tell me what it is? Thanks for help. Jason
0
9691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10505
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10276
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10253
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10035
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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 we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.