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

6 .net deployment windows-installer visual-studio

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

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

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

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

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.");
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

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

我有以下问题

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

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

Dou*_*rch 3

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

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