Fusion尝试加载未在任何地方引用的程序集

时间:2015-09-30 16:11:14

标签: .net .net-assembly filenotfoundexception fusion

当我尝试签署我的项目时,我发现Fusion尝试加载某些不存在的dll。这显然会失败,但我不明白为什么它会尝试加载这些dll。在我使用的不同项目中,我无法在任何地方找到对这些dll的引用。

fuslogvw为其中一个dll提供了以下输出:

*** Assembly Binder Log Entry  (28-9-2015 @ 16:29:53) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  D:\Projects\<snip>.vshost.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = RecentItemsManager.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b9588042c0f5ae4b, processorArchitecture=MSIL
 (Fully-specified)
LOG: Appbase = file:///D:/Projects/<snip>/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = <snip>.vshost.exe
Calling assembly : System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Projects\<snip>\bin\Debug\<snip>.vshost.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: RecentItemsManager.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b9588042c0f5ae4b, processorArchitecture=MSIL
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///D:/Projects/<snip>/bin/Debug/RecentItemsManager.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///D:/Projects/<snip>/bin/Debug/RecentItemsManager.XmlSerializers/RecentItemsManager.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///D:/Projects/<snip>/bin/Debug/RecentItemsManager.XmlSerializers.EXE.
LOG: Attempting download of new URL file:///D:/Projects/<snip>/bin/Debug/RecentItemsManager.XmlSerializers/RecentItemsManager.XmlSerializers.EXE.
LOG: All probing URLs attempted and failed.

在这种情况下,它会尝试加载RecentItemsManager.XmlSerializers,它可能曾经存在于其中一个项目中但几个月前已被删除。 我尝试使用Windows Grep在我的大多数磁盘上查找这些字符串的任何实例,但它也找不到任何东西。有没有人对如何解决这个问题有任何想法?

1 个答案:

答案 0 :(得分:0)

关注@ ama1111的链接,我做了一些研究,发现.NET XmlSerializers是在运行时生成的。我设法使用sgen构建缺少的dll,现在它不再抱怨丢失的dll,因为它们是在编译期间构建的。

您可以在Build选项卡下的项目属性中自动在Visual Studio中构建这些dll。如果将生成序列化程序集转为打开,则应始终构建它们。 但是,它只对Web服务序列化执行此操作。当您使用自己的XmlSerialization类时,它不会生成DLL,除非您确保sgen不使用/ p(roxytypes)参数运行。您无法在Visual Studio构建选项卡中指定此项,但您可以编辑csproj文件来执行此操作:

<GenerateSerializationAssemblies>On</GenerateSerializationAssemblies>
<SGenUseProxyTypes>false</SGenUseProxyTypes>

让我感到困惑的一件事是,我不能成为第一个想要为包含XmlSerializer的项目添加强名称的人。如果默认行为是在运行时生成这些dll,我无法看到这对于任何人来说都是开箱即用的。

相关问题