C#.NET開發ActiveX控制項

來源:互聯網
上載者:User

標籤:blog   http   使用   ar   art   cti   html   log   

最近剛開發了個activeX控制項,下面是我的一些簡單總結。 

1. 先建立一個類庫項目,在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頁面上使用<object id="id" classid="clsid:{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" ></object>擷取activeX控制項,並調用方法成功。注意:此處未對控制項添加認證,所以要想訪問到控制項,需設定瀏覽器安全資訊,這個就不多說了。 

相關參考連結: 
http://blog.sina.com.cn/s/blog_458983150100esga.html 
http://blog.163.com/[email protected]/blog/static/2349868720121195250522/ 
http://xu.xue.yi.blog.163.com/blog/static/9573824820101114111941871/ 
http://www.woxihuan.com/139766224/1336830428086975.shtml 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.