How to deploy a .Net assmebly for COM use through CAB on Web Page

How   to   deploy   a   .Net   assmebly   for   COM   use   through   CAB   on   Web   Page  
   
  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. 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值