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

Fusion attempting to load assembly that's not referenced anywhere

当我尝试签署我的项目时,我发现 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 在我的大部分磁盘上查找这些字符串的任何实例,但它也找不到任何东西。有人知道我该如何解决这个问题吗?

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

您可以在“构建”选项卡下的项目属性中自动构建 Visual Studio 中的那些 dll。如果您将 Generate serialization assembly 设置为 On,它应该始终构建它们。 但是,它只对 web 服务序列化执行此操作。当您使用自己的 XmlSerialization 类 时,它不会生成 dll,除非您确保 sgen 不 运行 带有 /p(roxytypes) 参数。您不能在 Visual Studio 构建选项卡中指定它,但您可以编辑 csproj 文件来执行此操作:

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

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