0

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

4

1 回答 1

0

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

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

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

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

于 2015-10-02T12:04:50.643 回答