技術討論區 > .NET程式設計討論區
Add .net Component into COM
(1/1)
小徒兒:
1. new one Project : ComponentB ClassB method: HelloB
2. Add references on .net
System.EnterPriseService
Microsoft Visual Basic Runtime Library
3.
using System.EnterpriseServices;
using Microsoft.VisualBasic;
4./Tool/build GUID/Registry Format
5. Copy and Past before Class constructor
[ComClass("B042CDBD-AE20-48ad-9180-9F2060706D8A","B042CDBD-AE20-48ad-9180-9F2060706D8B","B042CDBD-AE20-48ad-9180-9F2060706D8C")]
public class ClassB
A B C , BC is write by your self arbitary
6. build the class
小徒兒:
in vs .net command tool
1. generate the key
sn -k key.snk
2. add in the project
[assembly: AssemblyKeyFile("key.snk")]
3. generate the tlb file for example the component nadmed componentB Class named ClassB
tlbexp ComponentB.dll /out:HelloB.tlb
4. register the dll
regasm /tlb:HelloB.tlb ComponentB.dll
5.Add this dll into Cache
gacutil /i ComponentB.dll
小徒兒:
1. control tool/component managemnt/add one application
this application is for network applicatioin and 互動式
2. add the component into the application
add new componenet
/visual studio project/Component B/bin/Debug/HelloB.tlb
小徒兒:
--- 代碼: ---
<%
'Set obj=CreateObject("ClassLibraryA.ClassA")
'Set obj=CreateObject("ClassLibraryA.ClassA")
'Set obj=CreateObject("ADODB.Connection")
Set obj=CreateObject("ComponentB.ClassB")
's=obj.HelloB()
' s=obj.HelloA()
Response.Write s
%>
--- 程式碼結尾 ---
小徒兒:
1. click the component you want to export then right click to export
choose the locattion
for example: C:/test.msi
and checked it as the proxy application
2. locate this file on the public folder that others can access
after they install, they can call the .dll file as the component is locally
導覽
[0] 文章列表
前往完整版本