在 CAB 中部署 C# ActiveX 以供 Internet Explorer 使用 [英] Deploy C# ActiveX in a CAB for Internet Explorer use

查看:18
本文介绍了在 CAB 中部署 C# ActiveX 以供 Internet Explorer 使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拼命地尝试将用 C# 开发的 IE 的 ActiveX 部署为 CAB 存档.我已经阅读了很多资源(其中一些来自 StackOverflow),似乎很多人都遇到了同样的问题.我尝试了 3 种解决方案:a) 创建 CAB VS 项目,b) 使用 CABARC 手动创建 CAB,并在 INF 中注册 COM,c) 手动创建 CAB,启动 msiexec.他们都没有工作.我什至尝试过 d) 创建一个启动 msiexec 的引导程序但无济于事(因为有些人建议在 Vista 上简单地启动 msiexec 行不通).

I am desperately trying to deploy an ActiveX for IE developed in C# as a CAB archive. I have read many resources (some of them from StackOverflow) and it appears a lot of people are having the same problems. I have tried 3 solutions: a) creating a CAB VS project, b) manually creating a CAB using CABARC with a COM registration in INF and c) manually creating a CAB with launching msiexec. None of them worked. I even tried d) creating a bootstrapper which launches msiexec to no avail (because some people suggested simply launching msiexec on Vista can't work).

我运行的是 Windows Vista,但我的项目即使在 XP 上的 IE6 上也无法运行.

I am running Windows Vista but my project fails to run even on IE6 on XP.

当我使用 MSI 安装 ActiveX 时,在所有 Windows 上一切正常.显然 CAB 的事情不起作用,我还没有找到调试整个过程的正确方法.

When I install ActiveX using MSI, all is fine on ALL Windows. Apparently CAB thing is not working and I could not find a proper way to debug this whole process yet.

感谢任何帮助.

推荐答案

更新:请注意,这个古老但出色的答案仍然是如何解决这个问题的一个很好的大纲,至少在进化尺度上如Win7和IE11.我刚刚使用 Answerer 的 Firebreath.org 工具集作为起点,成功地完成了所有工作.这并不简单,但可以做到.我已经在下面的参考列表中添加了对该项目的引用,因为它可能为当前的开发人员提供比此概述更合乎逻辑的起点.

万岁 - 我刚刚完成了一个相同的项目,所以你会很高兴知道它实际上是可能的.我只在 XP 上测试过 - 我知道可能存在 Vista/7 不允许调用 msiexec 的问题.

Hooray - I have just finished an identical project, so you'll be pleased to know that it's actually possible. I have only tested this on XP - I understand there may be issues where Vista/7 don't allow msiexec to be called.

鉴于您有一个正确公开 COM 接口的程序集,我执行了以下操作:

Given that you have an assembly correctly exposing a COM interface, I did the following:

  • 强命名程序集.
  • 创建了一个 INF 文件
  • 使用 Visual Studio 2008安装项目"模板创建了一个 MSI.
  • 使用与 Windows XP 捆绑的iexpress.exe"创建了一个 CAB 文件.

我使用的 *.inf 文件看起来像:

The *.inf file I used looks like:

[version]
signature="$CHICAGO$"
AdvancedINF=2.0

[Setup Hooks]
install=install

[install]
run=msiexec.exe /package """%EXTRACT_DIR%SampInst.msi""" /qn

您唯一需要更改的是SampInst.msi.注意我会使用 8.3 文件名,因为长文件名会导致问题.在测试时,我也不会使用 qn 开关,因为这是静默安装.

The only bit you should need to change is the SampInst.msi. Note I would use an 8.3 filename, as long filenames can cause issues. While testing, I would not use the qn switch either, as that is a silent install.

安装程序只需要做一件事,那就是通过调用 RegAsm 来注册程序集.大多数安装程序会提供一些方法来轻松完成此操作.例如,通过 VS 2008 创建的安装程序只需要将程序集的注册"属性设置为vsdrpCOM".请注意,应选择 vsdrpCOM,因为它会在构建时生成适当的注册表项.vsdrpCOMSelfRegistration 设置可能会失败,因为它在运行时调用 RegAsm,因此不适用于非管理员.

The installer has to do only one thing, and that is register the assembly by calling RegAsm on it. Most installers will provide some method to easily do this. For example, an installer created through VS 2008 will simply need to have the "Register" property of the assembly set to "vsdrpCOM". Note that vsdrpCOM should be chosen as it generates the appropriate registry entries at build-time. The vsdrpCOMSelfRegistration setting is likely to fail as it calls RegAsm at run-time, and will thus not work for non-administrators.

这可以由任何 cab 存档器完成.Windows XP 包含 iexpress.exe,一个向导驱动的归档程序,而 Microsoft 的 CAB SDK 包含 cabarc.exe.其他 3rd 方工具也可用.请注意,如果您要签署 CAB,则需要在 CAB 文件中为代码签名保留空间.

This can be done by any cab archiver. Windows XP contains iexpress.exe, a wizard driven archiver, while Microsoft’s CAB SDK contains cabarc.exe. Other 3rd-party tools are also available. Note that you will need to reserve space in the CAB file for code-signing if you are going to sign the CAB.

您需要对 INF 文件和 MSI 文件进行 CAB.您不需要 CAB Setup.Exe 文件.

You will need to CAB the INF file, and the MSI file. You will not need to CAB the Setup.Exe file.

方便的提示:VS2008 安装项目项目类型允许您在属性中设置构建后步骤,因此您可以在一个步骤中构建和 CAB.我的构建后步骤如下所示:

Handy hint: The VS2008 Setup Project project type allows you to set a post-build step in the properties, so you can build and CAB in a single step. My post-build step looks like:

cd "$(ProjectDir)"
"%WINDIR%System32Makecab.exe" /f "VboCslib.ddf"

DDF 文件格式已记录.

对象标记用于指向包含安装程序的 cab 文件.将部署 ActiveXControl 的一个非常简单的 HTML 页面将是:

The object tag is used to point to the cab file containing the installer. A very simple HTML page which would deploy an ActiveXControl would be:

<html>
<head></head>
<body>

    <!--
        ID :    The id of the ActiveX control to be used in JavaScript.
        CLASSID : The GUID associated with the ActiveX control.
        CODEBASE: The location containing the CAB installer for the ActiveX 
       control. This could be a URL, or a relative path.
        -->
    <OBJECT ID="MyActiveXControl"
            CLASSID="CLSID:FC36FAE1-48E0-4f6b-B469-E1B5A8C6D1AC"
            CODEBASE="cabfilesSampleCabFile.CAB#version=1,0,0,0">
        </OBJECT>

        <script>
            MyActiveXControl.SomeMethod();
        </script>
    </body>
    </html>

实用提示

  • 确保您的安装程序基于每个用户"而不是每个机器"进行安装.如果用户没有管理员权限,这将使其更有可能安装.
  • Internet Explorer 6 实际上提供了非常有用的诊断帮助.清除 Internet 临时文件,然后导航到网页.如果安装不起作用,请转到 Internet 临时文件,您将在其中看到几个文件.其中之一是以 ?CodeDownloadErrorLog 开头的错误日志.将它拖到您的桌面并在记事本中打开它,它会提供有关失败时尝试执行的操作的详细信息.

    Internet Explorer 6 actually provides a really useful diagnostic aid. Clear your Temporary Internet Files, then navigate to the web-page. If the installation does not work, go to your temporary internet files and you will see a couple of files in there. One of these will be an error log starting ?CodeDownloadErrorLog. Drag it to your desktop and open it in notepad, and it will give details on what it was trying to do when it failed.

    1. Microsoft KB247257 - 签署 .cab 文件的步骤
    2. MSDN – 关于 INF文件架构
    3. SN.EXE - 用强名称编写强程序莉>
    4. Nikolkos Craft – 如何:部署 .NET ActiveX 控件
    5. CodeProject – 逐步创建 ActiveX .NET
    6. CodeProject – 通过 CAB 文件下载 C# ActiveX 组件
    7. MSDN - ALLUSERS 属性(Windows)
    8. MSDN – 非-管理 ActiveX 控件
    9. MSDN – Microsoft 文件柜格式
    1. Microsoft KB247257 – Steps for signing a .cab file
    2. MSDN – About INF File Architecture
    3. SN.EXE - Code Strong Programs with Strong Names
    4. Nikolkos Craft – How To: Deploy .NET ActiveX Control
    5. CodeProject – Create ActiveX .NET Step by Step
    6. CodeProject – Downloading C# ActiveX Components through CAB file
    7. MSDN - ALLUSERS Property (Windows)
    8. MSDN – Non-Admin ActiveX Controls
    9. MSDN – Microsoft Cabinet Format

    更新:Firebreath.org 有一个工具集,可以为许多平台生成浏览器插件.解决这里提出的问题的 IE/ActiveX 代码只是一个子集.但截至 2014 年 11 月 6 日,我发现开始使用 Firebreath 及其说明比尝试构建我的开发环境并从头开始推出我自己的所有解决方案更容易.

    Update: Firebreath.org has a toolset for generating browser plugins for many platforms. The IE/ActiveX code to solve the problem posed here is just a subset. But as of 6 Nov 2014, I found it easier to start with Firebreath and its instructions than to try to build up my dev environment and roll all my own solutions from scratch.

    这篇关于在 CAB 中部署 C# ActiveX 以供 Internet Explorer 使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆