473,406 Members | 2,378 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,406 software developers and data experts.

Problem with GetType().InvokeMember

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.

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().InvokeMember("TestMethod",
BindingFlags.InvokeMethod,null,obj,Parameters);
}

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

Thanks,
Vinoth

Nov 17 '05 #1
2 8166
vi****@gsdindia.com wrote:
object result = obj.GetType().InvokeMember("TestMethod",
BindingFlags.InvokeMethod,null,obj,Parameters);


You'll have to make this

BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public

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().InvokeMember("TestMethod",
BindingFlags.InvokeMethod,null,obj,Parameters);


You'll have to make this

BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public

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
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...
1
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...
0
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 =...
0
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...
1
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...
7
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
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...
2
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...
1
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...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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
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
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...
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
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...

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.