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.

  • 相关阅读:
    16平衡树
    15二叉检索树
    11用户权限
    10触发器
    8函数
    8存储过程
    linux下如何进入单用户模式
    RHEL6.4 字符模式下安装图形界面图文教程
    杂记
    Java内存管理(一):深入Java内存区域
  • 原文地址:https://www.cnblogs.com/chucklu/p/9883742.html
Copyright © 2011-2022 走看看