I write a simple Activex (just show alert Hello World) but I can't acces to my method HelloWorld of my C# program when I call ActiveX in a my JavaScript function
This is my C# program
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace DemoCSharpActiveX
{
[ProgId("DemoCSharpActiveX.HelloWorld")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("1c61c720-ce70-40e5-9e88-714469911fb3")]
[ComVisible(true)]
public class HelloWorld
{
[ComVisible(true)]
public String SayHello()
{
return "Hello World!";
}
}
}
My html file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>WebForm1</title>
</head>
<body>
<OBJECT id="DemoCSharpActiveX" classid="clsid:1c61c720-ce70-40e5-9e88-714469911fb3" VIEWASTEXT></OBJECT>
<script type="text/javascript">
try {
var obj = document.DemoCSharpActiveX;
if (obj) {
alert(obj.SayHello());
} else {
alert("Object is not created!");
}
} catch (Err) {
alert(Err.description);
}
</script>
</body>
</html>
If I execute my html file I get this error :
Object does not support this property or method