Case by Case..

Wang Ting's Tech Blog
随笔 - 40, 评论 - 250, 引用 - 12

导航

关于

勿发广告,谢谢配合

标签

每月存档

最新留言

广告

 

To create a .Net assembly which will be used by COM clients:

1. Create a VB.Net Class Library named “ClassLibraryVBActiveX”. Use the following code for the project:

Imports System.Runtime.InteropServices
<GuidAttribute("BC2E2273-E3D8-4AEA-8A4F-799574803D89"), ProgIdAttribute("ClassLibraryVBActiveX.Class1")> _
Public Class Class1
    Public Function Hello() As String
        Return "Hello World!"
    End Function
End Class

Please keep a note of the GUID. We will use it later.

2. Right click the class library project in the Solution Explorer and select “Properties”. This will open the Property Pages of the class library project. Under the category “Configuration Properties” | “Build”, check the check box “Register for COM Interop”.

3. Build the class library project.

To create a Setup project for the class library:

4. Right-click the solution in the Solution Explorer and select “Add” | “New Project”. Select “Setup Project” and name it as “ActiveXInstaller”.

5. Add the “Primary output” of the class library to the Setup project.

6. Build the Setup project. We should see that “ClassLibraryVBActiveX.dll” and “ClassLibraryVBActiveX.tlb” have been built into the Setup project.

To build the CAB file for the Setup project:

7. Extract the ZIP attached and save the files to a temporary folder.

 <Attachment is not available>

We have the following 5 files:

makecab.exe – The utility for building CABs. The utility can typically be found in “System32”.

Installer.inf – The Inf file for the CAB file. It has the following contents:

[Setup Hooks]
hook1=hook1

[hook1]
run= msiexec /i %EXTRACT_DIR%\ActiveXInstaller.msi /qn

[Version]
; This section is required for compatibility on both Windows 95 and Windows NT.
Signature="$CHICAGO$"
AdvancedInf=2.0

Here “run” specifies the command we would like to run after IE extracts the CAB. The command line will install the MSI “ActiveXInstaller.msi” under silent mode. You may refer to the following links for more details about the format of INF:

About INF File Architecture
http://msdn.microsoft.com/library/default.asp?url=/workshop/delivery/download/overview/infarchitecture.asp?frame=true

Cab.DDF – a text file with the following contents:

.OPTION EXPLICIT
.Set Cabinet=on
.Set Compress=on
.Set MaxDiskSize=CDROM
.Set ReservePerCabinetSize=6144
.Set DiskDirectoryTemplate="."
.Set CompressionType=MSZIP
.Set CompressionLevel=7
.Set CompressionMemory=21
.Set CabinetNameTemplate="ActiveX.CAB"
"Installer.inf"
"ActiveXInstaller.msi"

This file is a directive file for the “MakeCAB.exe” utility. “ActiveX.CAB” is the output name of the CAB. The last two lines indicate the two files we would like to include into the CAB.

Make.bat – a batch file that will run the following command to build the CAB:

MAKECAB.EXE /f "Cab.DDF"

TestPage.htm – a template HTML that will install the CAB:

<HTML>
<BODY>
<OBJECT ID="ClassLibraryVBActiveX"
CLASSID="CLSID:BC2E2273-E3D8-4AEA-8A4F-799574803D89"
CODEBASE="ActiveX.CAB#version=1,0,0,0">
</OBJECT>
</BODY>
</HTML>

Note that the GUID should match the GUID in our VB.Net code.

8. To use these files, please copy output MSI of the Setup project (e.g. “ActiveXInstaller.msi”) to the same folder as the files above. Then double-click “Make.bat” to build the CAB.

9. Copy the CAB as well as “TestPage.htm” to a web folder and test it.

Note that this approach also provides a way for the end user to uninstall the assembly. We can remove it by “Add/Remove Programs” applet.

打印 | 张贴于 2004-09-08 20:43:00 | Tag:暂无标签

留言反馈

#回复: How to deploy a .Net assmebly for COM use through CAB on Web Page 编辑
great! I try it , and no problem!
but , it request the client side setup every time .
what about "hook"?
would u give me an example? thank u!!
2007-07-12 22:09:00 | [匿名:mylove5193]
#使用.net framework 2.0用c#编写ActiveX控件(编写,部署,升级更新) 编辑
大概在1个半月前,自己探索了一下如何使用C#在.net 2.0 framework下编写ActiveX的东西。发现中文资料不多,而且被大家广为转载的中文资料还有错误(不知道是否是因为net 2.0和1.0有出入的关系)。最近Lori又要做相关方面的工作。所以也就算写上一个书面的东西以便他的参考,而且也算是对以前的工作的总结。免得忘记了。
本文包括了如何编写,部署,还有更新ActiveX控件

国内广为转载的那篇介绍如何使用C#的程序的文章的出处就是:
http://www.cnblogs.com/homer/archive/2005/04/01/86473.html(一共三篇)...
2006-05-11 17:50:00 | [匿名:彬彬]
#re: How to deploy a .Net assmebly for COM use through CAB on Web Page 编辑
I have not tested it yet but I believe the version of the component in "Downloaded Program Files" does not matter.

The COM component version checking should be based on the value in registry under HKEY_CLASSES_ROOT.
2005-06-13 00:45:00 | [匿名:Wang Ting]
#re: How to deploy a .Net assmebly for COM use through CAB on Web Page 编辑
There is another issue here. After the cab is downloaded and installed, the component under %WINDIR%\Downloaded Program Files contains the version of the msi file which you can not control. This version however is the criterio to re-download and re-install a new cab if it has changed. Do you know any way to control the version recorded under the %WINDIR%\Downloaded Program Files folder?
2005-06-09 18:34:00 | [匿名:Dimitris Papadimitriou]
#re: How to deploy a .Net assmebly for COM use through CAB on Web Page 编辑
final step:
to signcode the Cab.
2004-09-12 15:33:00 | [匿名:leighsword]
#How to deploy a .Net assmebly for COM use through CAB on Web Page (转) 编辑
Ping Back来自:blog.csdn.net
2004-09-10 13:53:00 | [匿名:xdev]
对不起,目前本随笔不允许发表新评论.

Powered by: Joycode.MVC引擎 0.5.2.0