最近剛開發(fā)了個activeX控件,下面是我的一些簡單總結。
1. 先創(chuàng)建一個類庫項目菱肖,在AssemblyInfo.cs設置 [assembly: ComVisible(true)]
,意思是使此程序集中的類型對COM組件可見。使用命名空間using System.Runtime.InteropServices;設置[assembly: System.Security.AllowPartiallyTrustedCallers()]乾蓬,保證程序集的可訪問。
2.在自定義的類上用vs自帶工具生成新的GUID慎恒,放在類前任内,如[Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")]。同時在生成標簽頁勾選“為Com互操作注冊”融柬,編譯生成死嗦,在注冊表下可以找到對應注冊碼。注意:win7下用管理員權限打開IDE粒氧。
3.在web頁面上使用獲取activeX控件越除,并調用方法成功。注意:此處未對控件添加證書外盯,所以要想訪問到控件摘盆,需設置瀏覽器安全信息,這個就不多說了饱苟。
相關參考鏈接:
http://blog.sina.com.cn/s/blog_458983150100esga.html
http://blog.163.com/tom19900920@126/blog/static/2349868720121195250522/
http://xu.xue.yi.blog.163.com/blog/static/9573824820101114111941871/
http://www.woxihuan.com/139766224/1336830428086975.shtml