在 CAB 中部署 C# ActiveX 以供 Internet Explorer 使用
我正在拼命尝试部署一个用 C# 开发的 IE 的 ActiveX 作为 CAB 存档。我阅读了很多资源(其中一些来自 StackOverflow),似乎很多人都遇到了同样的问题。我尝试了 3 种解决方案:a) 创建 CAB VS 项目,b) 使用 CABARC
手动创建 CAB,并在 INF 中进行 COM 注册,c) 通过启动 msiexec.他们都没有工作。我什至尝试过 d) 创建一个启动
msiexec
的引导程序,但没有成功(因为有些人建议在 Vista 上简单地启动 msiexec
是行不通的)。
我运行的是 Windows Vista,但我的项目即使在 XP 上的 IE6 上也无法运行。
当我使用 MSI 安装 ActiveX 时,在所有 Windows 上一切正常。显然 CAB 的东西不起作用,我还找不到调试整个过程的正确方法。
任何帮助表示赞赏。
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).
I am running Windows Vista but my project fails to run even on IE6 on XP.
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.
Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新:请注意,这个古老但优秀的答案仍然是如何解决此问题的一个非常好的概述,至少沿着 Win7 和 IE11 的进化规模。我刚刚使用 Answerer 的 Firebreath.org 工具集作为起点,成功地使这一切正常工作。这并不简单,但可以做到。我已将对该项目的引用添加到下面的参考列表中,因为它可能为当前开发人员提供比此概述更合乎逻辑的起点。
万岁 - 我刚刚完成了一个相同的项目,所以您将很高兴知道这实际上是可能的。我只在 XP 上对此进行了测试 - 我知道 Vista/7 可能存在不允许调用
msiexec
的问题。鉴于您有一个正确公开 COM 接口的程序集,我执行了以下操作:
创建 INF 文件
我使用的 *.inf 文件如下所示:
您唯一需要更改的部分是
SampInst.msi
。注意我会使用 8.3 文件名,因为长文件名可能会导致问题。在测试时,我也不会使用 qn 开关,因为这是静默安装。创建安装程序
安装程序只需执行一件事,那就是通过调用 RegAsm 来注册程序集。大多数安装程序都会提供一些方法来轻松完成此操作。例如,通过 VS 2008 创建的安装程序只需将程序集的“Register”属性设置为“vsdrpCOM”。请注意,应选择 vsdrpCOM,因为它会在构建时生成适当的注册表项。 vsdrpCOMSelfRegistration 设置可能会失败,因为它在运行时调用 RegAsm,因此不适用于非管理员。
将安装程序打包到 CAB 文件中
这可以通过任何 cab 归档程序来完成。 Windows XP 包含 iexpress.exe,一个向导驱动的归档程序,而 Microsoft 的 CAB SDK 包含 cabarc.exe。其他第三方工具也可用。
请注意,如果要签署 CAB,则需要在 CAB 文件中预留空间用于代码签名。
您将需要 CAB INF 文件和 MSI 文件。您不需要 CAB Setup.Exe 文件。
方便的提示:VS2008 安装项目项目类型允许您在属性中设置构建后步骤,这样您就可以在一个步骤中构建和 CAB。我的构建后步骤如下所示:
DDF 文件格式已记录。
HTML 页面示例
对象标记用于指向包含安装程序的 cab 文件。部署 ActiveXControl 的非常简单的 HTML 页面如下:
方便的提示
故障排除
Internet Explorer 6 实际上提供了非常有用的诊断帮助。清除您的临时 Internet 文件,然后导航到该网页。如果安装不起作用,请转到临时 Internet 文件,您将在其中看到几个文件。其中之一是以 ?CodeDownloadErrorLog 开头的错误日志。将其拖到桌面并在记事本中打开它,它将提供有关失败时尝试执行的操作的详细信息。
参考
更新:Firebreath.org 拥有用于为许多平台生成浏览器插件的工具集。解决这里提出的问题的 IE/ActiveX 代码只是一个子集。但截至 2014 年 11 月 6 日,我发现开始使用 Firebreath 及其说明比尝试构建我的开发环境并从头开始推出我自己的所有解决方案更容易。
Update: Note that this old but excellent answer is still a very good outline for how to approach solving this problem, at least as along the evolutionary scale as Win7 and IE11. I just succeeded making it all work using the Answerer's Firebreath.org toolset as a jumping off point. It's not simple but it can be done. I've added a reference to that project to the reference list below since it may make a more logical jumping off point for current developers than this overview is.
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.Given that you have an assembly correctly exposing a COM interface, I did the following:
Create INF file
The *.inf file I used looks like:
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.Create the Installer
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.
Package the installer into a CAB file
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.
You will need to CAB the INF file, and the MSI file. You will not need to CAB the Setup.Exe file.
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:
The DDF file format is documented.
Sample HTML page
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:
Handy hints
Trouble-shooting
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.
References
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.