Windows服务:抛出System.Reflection.ReflectionTypeLoadException并显示以下错误消息:无法加载一个或多个re

eLs*_*eLs 7 c# windows-services assembly-loading

我正在使用一个Windows服务,其中我有一个程序集的引用,复制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.
Run Code Online (Sandbox Code Playgroud)

另外有一点需要注意的是,如果我将副本本地化为.dll,那么安装就可以了.BUt我不想在安装之前加载它所以我想在运行时这样做.

提前致谢.

Mik*_*oud 0

这里还要注意的一件事是,如果我将该 .dll 复制到本地,那么安装就可以正常进行。但是我不想在安装之前加载它,所以我想在运行时加载它。

这并不重要,程序集仍然需要进入安装目录。如果设置Copy Localfalse,那么您仍然需要在安装时分发程序集。