M
Michiel
Hello,
I have an ActiveX control which I can call fine from HTML pages, using the
object tag like <OBJECT ID="UserControl1" WIDTH="0" HEIGHT="0"
CLASSID="CLSID:85A5119D-0000-0000-0000-5467CB71943E" CODEBASE =
http://mywebsite/MyActiveX.ocx#Version=1,1,0,0 VIEWASTEXT></OBJECT>
, and then simply adding them to the object's id with a . like
UserControl1.MyFunction()
in JavaScript.
But how do I do this from C# ?
I can't reference to the file directly (Visual Studio says "not a valid COM
component") so I figure I have to use something like
[ComImport, Guid("85A5119D-0000-0000-0000-5467CB71943E"), TypeLibType(4160)]
public class MyActiveX
{
[PreserveSig, MethodImpl(MethodImplOptions.InternalCall,
MethodCodeType=MethodCodeType.Runtime)]
public virtual extern int MyFunction();
}
And then calling it like
MyActiveX oAX=new MyActiveX();
oAX.MyFunction();
However, this gives me an ExecutionEngineException at the last line.
Thanks for any clues !
Michiel.
I have an ActiveX control which I can call fine from HTML pages, using the
object tag like <OBJECT ID="UserControl1" WIDTH="0" HEIGHT="0"
CLASSID="CLSID:85A5119D-0000-0000-0000-5467CB71943E" CODEBASE =
http://mywebsite/MyActiveX.ocx#Version=1,1,0,0 VIEWASTEXT></OBJECT>
, and then simply adding them to the object's id with a . like
UserControl1.MyFunction()
in JavaScript.
But how do I do this from C# ?
I can't reference to the file directly (Visual Studio says "not a valid COM
component") so I figure I have to use something like
[ComImport, Guid("85A5119D-0000-0000-0000-5467CB71943E"), TypeLibType(4160)]
public class MyActiveX
{
[PreserveSig, MethodImpl(MethodImplOptions.InternalCall,
MethodCodeType=MethodCodeType.Runtime)]
public virtual extern int MyFunction();
}
And then calling it like
MyActiveX oAX=new MyActiveX();
oAX.MyFunction();
However, this gives me an ExecutionEngineException at the last line.
Thanks for any clues !
Michiel.