zoukankan      html  css  js  c++  java
  • Could not load file or assembly 'MyAssembly.XmlSerializers

    https://stackoverflow.com/questions/17755559/could-not-load-file-or-assembly-myassembly-xmlserializers

    There's an answer already here. Apparently this is "expected behaviour" that MS isn't going to fix.

    The first comment has a workaround:

    One of the possible ways to get rid of this problem is check "Just my code" option in Tools -> Options -> Debugging -> General options

    XmlSerializer giving FileNotFoundException at constructor

    Like Martin Sherburn said, this is normal behavior. The constructor of the XmlSerializer first tries to find an assembly named [YourAssembly].XmlSerializers.dll which should contain the generated class for serialization of your type. Since such a DLL has not been generated yet (they are not by default), a FileNotFoundException is thrown. When that happenes, XmlSerializer's constructor catches that exception, and the DLL is generated automatically at runtime by the XmlSerializer's constructor (this is done by generating C# source files in the %temp% directory of your computer, then compiling them using the C# compiler). Additional constructions of an XmlSerializer for the same type will just use the already generated DLL.

    UPDATE: Starting from .NET 4.5, XmlSerializer no longer performs code generation nor does it perform compilation with the C# compiler in order to create a serializer assembly at runtime, unless explicitly forced to by setting a configuration file setting (useLegacySerializerGeneration). This change removes the dependency on csc.exe and improves startup performance. Source: .NET Framework 4.5 Readme, section 1.3.8.1.

    The exception is handled by XmlSerializer's constructor. There is no need to do anything yourself, you can just click 'Continue' (F5) to continue executing your program and everything will be fine. If you're bothered by the exceptions stopping the execution of your program and popping up an exception helper, you either have 'Just My Code' turned off, or you have the FileNotFoundException set to break execution when thrown, instead of when 'User-unhandled'.

    To enable 'Just My Code', go to Tools >> Options >> Debugging >> General >> Enable Just My Code. To turn off breaking of execution when FileNotFound is thrown, go to Debug >> Exceptions >> Find >> enter 'FileNotFoundException' >> untick the 'Thrown' checkbox from System.IO.FileNotFoundException.

  • 相关阅读:
    阅读笔记(四)——《代码整洁之道》1
    阅读笔记(一)——《需求工程——软件建模与分析》一
    数据提取
    HIVE数据清洗练习
    第八周hadoop-MapReduce
    小程序新增页面导航栏
    个人课程总结
    第十六周总结

    排序
  • 原文地址:https://www.cnblogs.com/chucklu/p/9883742.html
Copyright © 2011-2022 走看看