visual-studio Windows 安装程序出错...“无法获取安装程序类型”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/581750/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:12:15  来源:igfitidea点击:

Error with Windows Installer ... "Unable to get installer types"

.netvisual-studiodeploymentwindows-installer

提问by Scott Vercuski

I'm experiencing an error when using the windows installer to install an event source in a product I am deploying.

使用 Windows 安装程序在我正在部署的产品中安装事件源时遇到错误。

The error message I receive states the following ...

我收到的错误消息指出以下...

Unable to get installer types in the c:\temp\program.exe assembly. --> Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

无法在 c:\temp\program.exe 程序集中获取安装程序类型。--> 无法加载一种或多种请求的类型。检索 LoaderExceptions 属性以获取更多信息。

Here is the block of code that creates the event source installer ...

这是创建事件源安装程序的代码块...

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Diagnostics;

namespace myapplication
{
    [RunInstaller(true)]
    public partial class EventSourceInstaller : Installer
    {
        public EventSourceInstaller()
        {
            InitializeComponent();

            string eventSourceName = "MyAppSourceName";
            if (!EventLog.SourceExists(eventSourceName))
            {
                EventSourceCreationData data = new EventSourceCreationData(eventSourceName, "Application");
                EventLog.CreateEventSource(data);
                EventLog.WriteEntry(eventSourceName, "Source Added.");
            }
        }
    }
}

In the installer project I've added a custom action on Install named "Primary output from MyApplication (Active)" to run the event source installer.

在安装程序项目中,我在名为“MyApplication (Active) 的主要输出”的安装上添加了一个自定义操作来运行事件源安装程序。

I have the following questions

我有以下问题

  1. Has anyone else run across this and what was the issue?

  2. How do I go about retrieving the LoaderExceptions property of the installer?

  1. 有没有其他人遇到过这个问题,这是什么问题?

  2. 如何检索安装程序的 LoaderExceptions 属性?

采纳答案by Dour High Arch

I have never seen that error, but the path c:\temp\program.exe is very strange. Are you trying to run the installer from the c:\temp\ directory?

我从未见过那个错误,但是路径 c:\temp\program.exe 很奇怪。您是否尝试从 c:\temp\ 目录运行安装程序?

Are you certain the output of all projects and all third-party DLLs you use are included in the Deployment project? Click on all included files in the Deployment project and check their SourcePath property; are they to the original source files and not the target output folder? Not the temp folder?

您确定您使用的所有项目和所有第三方 DLL 的输出都包含在部署项目中吗?单击部署项目中所有包含的文件并检查它们的 SourcePath 属性;它们是原始源文件而不是目标输出文件夹吗?不是临时文件夹?

回答by Philipp

The "Detected Dependencies" of your setup project are not up to date. In my case refreshing the dependencies does not work. Due to adding an dll to the setup project dependencies visual studio refreshed them all. After rebuilding the setup project and the error didn't occurred any more!

您的安装项目的“检测到的依赖项”不是最新的。在我的情况下,刷新依赖项不起作用。由于向安装项目依赖项添加了一个 dll,visual studio 将它们全部刷新。重建安装项目后,错误不再发生!

回答by erikkallen

I had exactly the same problem.

我遇到了完全相同的问题。

I guess your program is referencing other DLLs which the installer install in the GAC or somewhere else outside of the application directory. You can't count on those DLLs being installed before your install action runs.

我猜你的程序引用了安装程序安装在 GAC 或应用程序目录之外的其他地方的其他 DLL。您不能指望在安装操作运行之前安装这些 DLL。

Solution: Create a separate DLL for your install action and make sure that DLL does not reference any other DLL (directly or indirectly) that are not installed inside your application folder.

解决方案:为您的安装操作创建一个单独的 DLL,并确保 DLL 不引用未安装在应用程序文件夹中的任何其他 DLL(直接或间接)。

BTW, if you can, switch to some other technology. I don't know which competitors are better, but if you do non-standard stuff, the VS install project will cause you nothing but trouble.

顺便说一句,如果可以,请切换到其他一些技术。我不知道哪个竞争对手更好,但如果你做非标准的东西,VS安装项目只会给你带来麻烦。

回答by LawMan

My problem was that I was using the 64 bit version of installutil.exe instead of the 32 bit version.

我的问题是我使用的是 64 位版本的 installutil.exe 而不是 32 位版本。

  • 32 bit path - C:\Windows\Microsoft.NET\Framework\v4.0.30319

  • 64 bit path - C:\Windows\Microsoft.NET\Framework64\v4.0.30319

  • 32 位路径 - C:\Windows\Microsoft.NET\Framework\v4.0.30319

  • 64 位路径 - C:\Windows\Microsoft.NET\Framework64\v4.0.30319