简体   繁体   English

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

[英]Error with Windows Installer ... "Unable to get installer types"

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.无法在 c:\temp\program.exe 程序集中获取安装程序类型。 --> Unable to load one or more of the requested types. --> 无法加载一种或多种请求的类型。 Retrieve the LoaderExceptions property for more information.检索 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.在安装程序项目中,我在 Install 上添加了一个名为“来自 MyApplication(活动)的 Primary output”的自定义操作来运行事件源安装程序。

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?我如何 go 关于检索安装程序的 LoaderExceptions 属性?

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.由于将 dll 添加到设置项目依赖项中,Visual Studio 刷新了它们。 After rebuilding the setup project and the error didn't occurred any more!重建安装项目后,错误不再发生!

I have never seen that error, but the path c:\temp\program.exe is very strange.我从未见过那个错误,但是路径 c:\temp\program.exe 很奇怪。 Are you trying to run the installer from the c:\temp\ directory?您是否尝试从 c:\temp\ 目录运行安装程序?

Are you certain the output of all projects and all third-party DLLs you use are included in the Deployment project?您确定所有项目的 output 和您使用的所有第三方 DLL 都包含在 Deployment 项目中吗? Click on all included files in the Deployment project and check their SourcePath property;单击 Deployment 项目中所有包含的文件并检查其 SourcePath 属性; are they to the original source files and not the target output folder?它们是原始源文件而不是目标 output 文件夹吗? Not the temp folder?不是临时文件夹?

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.我猜你的程序正在引用安装程序安装在 GAC 或应用程序目录之外的其他地方的其他 DLL。 You can't count on those DLLs being installed before your install action runs.您不能指望在安装操作运行之前安装这些 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安装项目只会给你带来麻烦。

Following things works for me关注事情对我有用

  1. Clean Solution清洁解决方案
  2. Close and restart visual studio关闭并重新启动视觉工作室
  3. Rebuild the solution重建解决方案

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 32 位路径 - C:\Windows\Microsoft.NET\Framework\v4.0.30319

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

I had the same problem.我有同样的问题。 The solution was to copy to the service's folder all dll's etc. from the bin\debug or bin\release folder解决方案是将 bin\debug 或 bin\release 文件夹中的所有 dll 等复制到服务的文件夹

I was getting the same exception when trying to install a windows service.尝试安装 windows 服务时,我遇到了同样的异常。 I tried the above but was simply copying a service from our dev environment to our live and I didn't realise the targeted version of .net was missing from the live server.我尝试了上述方法,但只是将服务从我们的开发环境复制到我们的现场,我没有意识到现场服务器中缺少 .net 的目标版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM