Click to See Complete Forum and Search --> : .NET ActiveX


gerotica
March 12th, 2009, 12:02 AM
Can anybody tell me why this code always returns "Object doesn't support this property or method" when AXClassLibTest is called from javascript? All the programming was made in VS 2008, so I assume all registrations, etc, were made for me right? And I know Internet Explorer can find the object, because it shows me the "InitAX" message when loaded...

namespace ActiveXClassLib
{
[Guid("75297D9E-B468-444b-AB31-D61B6B190A30")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComVisible(true)]
public interface IAXClassLib
{
void AXClassLibTest();
}

[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces(typeof(IAXClassLib))]
[Guid("CF61B7F1-8483-463e-9EB2-BEA2A40532A7")]
[ComVisible(true)]
public class AXClassLib : IAXClassLib
{
public void AXClassLibTest()
{
MessageBox.Show("Test OK");
}

public AXClassLib()
{
MessageBox.Show("InitAX");
}
}

aspx page:
<body>
<form id="form1" name="form1" runat="server">
<br />
<object id="MyActiveX" name="MyActiveX" classid="clsid:CF61B7F1-8483-463e-9EB2-BEA2A40532A7"
width="300" height="300" >
</object>
<br />
<input type="button" value="Click me" onclick="OpenActiveX2();"/>
</form>
<script language="javascript" type="text/javascript" >
function OpenActiveX2() {
document.MyActiveX.AXClassLibTest();
}
</script>
</body>


Thanks!