【问题标题】:Fusion attempting to load assembly that's not referenced anywhereFusion 尝试加载未在任何地方引用的程序集
【发布时间】:2015-10-02 20:04:50
【问题描述】:

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

【问题讨论】:

  • 您是否尝试过在干净的机器上构建代码(以前从未用于构建代码)?
  • Here's a post 关于无法找到 XmlSerializers。接受的答案表明这是预期的行为,并且异常在框架内被捕获和处理。
  • @xxbbcc 我已经在干净的存储库中尝试过,但没有运气,但我也会在干净的机器上尝试。感谢您的建议。
  • @ama1111 这似乎是相关的。点击你的链接有很多有用的信息我可以看看,谢谢!

标签: .net .net-assembly filenotfoundexception fusion


【解决方案1】:

按照@ama1111 的链接,我做了一些研究,发现.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,我看不出这对任何人来说是如何开箱即用的。

【讨论】:

    猜你喜欢
    • 2010-12-29
    • 2012-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-22
    • 2014-12-08
    相关资源
    最近更新 更多