I am trying to write a script engine host in C#, specifically the JScript
engine. I was wondering if anyone has a definition for the IActiveScriptXXX
interfaces in C# ? I have got so far by looking at the IDL and header
files, but came across a problem. I create the script engine and give it my
C# class (this) as the Site - it calls GetItemInfo to get a named item that
I added - but I am not sure how to define this function for .Net interop.
The problem seems to be that when the engine asks for an IUnknown pointer
(SCRIPTINFO_IUNKNOWN), the ITypeLib** pointer is not a valid pointer and
causes the .Net marshaller to crash. The only way I have been able to get
further is do define the GetItemInfo as follows :-
void GetItemInfo([In,MarshalAs(UnmanagedType.LPWStr)] string pstrName,
[In,MarshalAs(UnmanagedType.U4)] uint dwReturnMask,
[Out,MarshalAs(UnmanagedType.IUnknown)] out object ppiunkItem,
[Out,MarshalAs(UnmanagedType.Interface)] UCOMITypeLib ppti);
This is basically a hack, by making the 'ppti' a non-out param it is not
marshalled and I no longer get a crash, however I am unable to pass back
ITypeInfo if required (currently I don't need to do this).
Any help appreciated.