P
Paolo Dupont
I need to instantiate a component on a remote server. I did it easily.
However, i can not set the handler for the event associated with the class.
I'm able to implement and use events only if the remote server is the local
machine (quite useless ;-) )
// Code
Type dcomType;
Object dcomObj;
MyClass m_instance;
EventInfo evt;
dcomType = Type.GetTypeFromProgID("ProgId", "computerName", false);
dcomObj = Activator.CreateInstance(dcomType);
m_instance = (MyClass) Marshal.CreateWrapperOfType(dcomObj,
typeof(myClass));
evt = m_instance.GetType().GetEvent("MyEvent");
Delegate m_handler = new _IMyClass_myEventEventHandler(MyHandler);
evt.AddEventHandler(m_instance, m_handler);
//Failed with an exception 'System.Reflection.TargetInvocationException'
occurred in mscorlib.dll
//Additional information: Exception has been thrown by the target of an
invocation.
public void MyHandler(void)
{
....
}
The code works fine if the server is on the local machine.
Any advices ??
TIA, Paolo.
However, i can not set the handler for the event associated with the class.
I'm able to implement and use events only if the remote server is the local
machine (quite useless ;-) )
// Code
Type dcomType;
Object dcomObj;
MyClass m_instance;
EventInfo evt;
dcomType = Type.GetTypeFromProgID("ProgId", "computerName", false);
dcomObj = Activator.CreateInstance(dcomType);
m_instance = (MyClass) Marshal.CreateWrapperOfType(dcomObj,
typeof(myClass));
evt = m_instance.GetType().GetEvent("MyEvent");
Delegate m_handler = new _IMyClass_myEventEventHandler(MyHandler);
evt.AddEventHandler(m_instance, m_handler);
//Failed with an exception 'System.Reflection.TargetInvocationException'
occurred in mscorlib.dll
//Additional information: Exception has been thrown by the target of an
invocation.
public void MyHandler(void)
{
....
}
The code works fine if the server is on the local machine.
Any advices ??
TIA, Paolo.