Our app is mainly COM based. We allow .NET plug-ins. When a plug-in is
installed, it receives a COM pointer to the app. The plug-in implements our
IExtensionImpl interface and gets the app pointer through the OnCreate
method...
public void OnCreate(IApplication pApp)...
The plug-in that I'm working on also allows sub-plug-ins. These
sub-plug-ins are simple DLLs that provide methods that are accessed via
Reflection.
Here's my problem... I need to forward the IApplication pointer to the
sub-plug-in. Here's the sub-plug-in Create routine...
public void Create(IApplication app)...
The plug-in calls the sub-plug-in using the following Reflection code...
MethodInfo method = Reflect.GetNamedMethod(type, "Create",
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
Object[] parameters = new Object[1] { m_app }; // m_app was
cached in OnCreate()
Type t1 = parameters[0].GetType();
Type t2 = method.GetParameters()[0].ParameterType;
method.Invoke(testType, parameters);
The Invoke fails with a type mismatch:
t1 = System.__ComObject
t2 = IApplication
How do I get the types to match?
Shailen Sukul - 09 Nov 2006 01:14 GMT
http://www.mztools.com/articles/2006/MZ013.htm
http://support.microsoft.com/?kbid=320523
> Our app is mainly COM based. We allow .NET plug-ins. When a plug-in is
> installed, it receives a COM pointer to the app. The plug-in implements our
[quoted text clipped - 28 lines]
>
> How do I get the types to match?
John Lutz - 09 Nov 2006 14:12 GMT
Thanks for the information. I tried the following:
Object[] parameters = new Object[1] { m_app as IApplication };
It didn't fix the problem. I still get a type mismatch exception. It
seems like I either need to make my reflected method have a signature like
this...
void Create(System.__ComObject app)
Or else figure out how to make the Object array constructor convert my
interface pointer to something other than System.__ComObject.
I looked at some of the Marshalling routines but I really want to keep
everything in-process.
> http://www.mztools.com/articles/2006/MZ013.htm
> http://support.microsoft.com/?kbid=320523
[quoted text clipped - 31 lines]
> >
> > How do I get the types to match?