.net - ActiveX C# : acces to method of C# file -
i write simple activex (just show alert hello world) can't acces method helloworld of c# program when call activex in javascript function
this 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 not created!"); } } catch (err) { alert(err.description); } </script> </body> </html> if execute html file error :
object not support property or method
are sure activex registered in system , initialized?
your activex not implement iobjectsafety interface ie not run normaly. check security zone demo page land in , set setting 
also, might want @ this example , if want install activex cab this question
Comments
Post a Comment