Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Windows服务:System.Reflection.ReflectionTypeLoadException引发了以下错误消息:无法加载一个或多个re_C#_Windows Services_Assembly Loading - Fatal编程技术网

C# Windows服务:System.Reflection.ReflectionTypeLoadException引发了以下错误消息:无法加载一个或多个re

C# Windows服务:System.Reflection.ReflectionTypeLoadException引发了以下错误消息:无法加载一个或多个re,c#,windows-services,assembly-loading,C#,Windows Services,Assembly Loading,我使用的是一个windows服务,其中我有一个程序集的引用,它是copy local=false。但我尝试在运行时加载它,虽然在visual studio中运行时工作正常,但在尝试安装时,cmd会出现以下错误: An exception occurred while trying to find the installers in the D:\Official\Pro jects\20131007_ImproveDN\build\debug\application s\Subscription

我使用的是一个windows服务,其中我有一个程序集的引用,它是copy local=false。但我尝试在运行时加载它,虽然在visual studio中运行时工作正常,但在尝试安装时,cmd会出现以下错误:

An exception occurred while trying to find the installers in the D:\Official\Pro
jects\20131007_ImproveDN\build\debug\application
s\SubscriptionService\SubscriptionService.exe assembly.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the
 requested types. Retrieve the LoaderExceptions property for more information.
Aborting installation for D:\Official\Projects\2
0131007_ImproveDN\build\debug\applications\SubscriptionService\SubscriptionServi
ce.exe.
An exception occurred during the Rollback phase of the System.Configuration.Inst
all.AssemblyInstaller installer.
System.InvalidOperationException: Unable to get installer types in the D:\Offici
al\Projects\\20131007_ImproveDN\build\debug\appli
cations\SubscriptionService\SubscriptionService.exe assembly.
The inner exception System.Reflection.ReflectionTypeLoadException was thrown wit
h the following error message: Unable to load one or more of the requested types
. Retrieve the LoaderExceptions property for more information..
An exception occurred during the Rollback phase of the installation. This except
ion will be ignored and the rollback will continue. However, the machine might n
ot fully revert to its initial state after the rollback is complete.
这里还需要注意的一点是,如果我将.dll的copy local设置为true,那么安装就可以了。但是我不想在安装之前加载它,所以我想在运行时加载它

提前谢谢

这里还需要注意的一点是,如果我将.dll的copy local设置为true,那么安装就可以了。但是我不想在安装之前加载它,所以我想在运行时加载它


这并不重要,程序集仍然需要进入安装目录。如果将
Copy Local
设置为
false
,则仍然需要将程序集与安装一起分发。

我遇到了类似的问题。我做了以下对我有用的事情

  • 首先,使用FuseLog(程序集绑定查看器)找出绑定失败的地方(

  • 当我开始获取日志时,我注意到日志中的内容是“文件中的程序集平台或内容类型无效(hr=0x8007000b)”

  • 我的解决方案由3个项目组成。我检查了每个项目的构建属性,发现其中一个是针对“x86”的。我将其更改为“任意CPU”,重新编译,问题就解决了

也许您需要使用其他版本的InstallUtil.exe:

  • c:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe
  • c:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe
  • c:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe
  • c:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe

尝试使用Framework64子文件夹中的x64版本。

这就是我在这里缺少的内容,您知道如何在不将其复制到本地的情况下执行此操作吗=true@eLs,这实际上完全取决于您如何分发应用程序。好的,但我有一个program.cs,在主函数中,我正在为其他DLL使用汇编解析器它们没有被引用,但在运行时加载。但是创建问题的程序集被引用并在代码中使用。这对我很有帮助,谢谢!我使用VS 2017的开发人员命令提示符,但最终失败了,抱怨上面报告的错误。我仍然不明白为什么会发生这种情况,并从Fram运行installutil.exeework64版本成功了。也许,DEV 2017命令提示符没有指向最新的installutil.exe?