XmlSerializerでエラーが発生したのはなぜですか?
-
08-07-2019 - |
質問
作業中のアプリケーションにいくつかの変更を加え、このコード行で次のエラーが発生し始めました。
Dim Deserializer As New Serialization.XmlSerializer(GetType(Groups))
これがエラーです。
BindingFailure was detected
Message: The assembly with display name 'FUSE.XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'FUSE.XmlSerializers, Version=8.11.16.1, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'FUSE.XmlSerializers, Version=8.11.16.1, Culture=neutral, PublicKeyToken=null'
Message: The assembly with display name 'FUSE.XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'FUSE.XmlSerializers, Version=8.11.16.1, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'FUSE.XmlSerializers, Version=8.11.16.1, Culture=neutral, PublicKeyToken=null'
=== Pre-bind state information ===
LOG: User = DOUG-VM\Doug
LOG: DisplayName = FUSE.XmlSerializers, Version=8.11.16.1, Culture=neutral, PublicKeyToken=null, processorArchitecture=MSIL
(Fully-specified)
LOG: Appbase = file:///E:/Laptop/Core Data/Data/Programming/Windows/DotNet/Work Projects/NOP/Official Apps/FUSE WPF/Fuse/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: E:\Laptop\Core Data\Data\Programming\Windows\DotNet\Work Projects\NOP\Official Apps\FUSE WPF\Fuse\bin\Debug\FUSE.vshost.exe.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///E:/Laptop/Core Data/Data/Programming/Windows/DotNet/Work Projects/NOP/Official Apps/FUSE WPF/Fuse/bin/Debug/FUSE.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///E:/Laptop/Core Data/Data/Programming/Windows/DotNet/Work Projects/NOP/Official Apps/FUSE WPF/Fuse/bin/Debug/FUSE.XmlSerializers/FUSE.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///E:/Laptop/Core Data/Data/Programming/Windows/DotNet/Work Projects/NOP/Official Apps/FUSE WPF/Fuse/bin/Debug/FUSE.XmlSerializers.EXE.
LOG: Attempting download of new URL file:///E:/Laptop/Core Data/Data/Programming/Windows/DotNet/Work Projects/NOP/Official Apps/FUSE WPF/Fuse/bin/Debug/FUSE.XmlSerializers/FUSE.XmlSerializers.EXE.
何が起こっているのですか?
解決
これが起こった主な理由は、シリアライズとデシリアライズしようとしている型が一致しないためです。 (グループの)ObservableCollectionをシリアライズし、(グループの)ObservableCollectionを継承したビジネスオブジェクト-グループをデシリアライズしていました。
そしてこれも問題の一部でした... 差出人- http:// social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/9f0c169f-c45e-4898-b2c4-f72c816d4b55/
この例外は、 XmlSerializerの通常の操作。それ 予想され、キャッチされます フレームワークコード内で処理されます。 無視して続行してください。それであれば デバッグ中に煩わしい、設定 停止するだけのVisual Studioデバッガー すべてではなく未処理の例外 例外。
他のヒント
私が見つけた情報によると、XmlSerializersに関連付けられたBindingFailure例外はエラーを示さない場合があり、単に無視する必要がありますが、場合によってはiを見ることができます。 e。デバッグモードで、スローされたすべての例外を表示するようにVSオプションを設定した場合。
ところで。これは、多かれ少なかれ、最初の回答で言及したことの1つです:)。
アセンブリFUSE.XmlSerializersを見つけることができないようです。 アセンブリバインドログビューアー(Fuslogvw.exe)で、どこを見ているかを確認します(ただし、上記のリストはかなりいっぱいに見えます)。
このアセンブリのコンピューター上の保存場所を見つけて、 NGen を実行します何らかの理由でロードに失敗しているかどうかを確認してください。このDLLファイルが Bin \ Debug ディレクトリに表示されていることを確認してください。 Visual Studioは依存関係の依存関係を取得していないようです。そのため、必要なファイルがすべて揃っていることを確認する必要があります。
Groups
タイプを含むアセンブリをどのようにロードしましたか? XMLシリアライザーがシリアル化のためにアセンブリをロードしようとするために同じコンテキスト( 'LoadFrom'コンテキスト)を使用しているため、 Assembly.LoadFrom()
でロードしたと思います。その場合、いくつかのオプションがあります:
- Assembly.LoadFrom()の代わりに
Assembly.Load()
を使用します。 - ハンドラーを
AppDomain.AssemblyResolve
に接続して、CLRが問題のアセンブリを見つけられるようにします。
これが厄介な場所にあるいくつかのVisual Studioプロジェクトでは、 BindingFailure および System.IO.FileNotFoundException のみの例外ブレークを無効にすることを好みます。 。
Visual Studio:例外ダイアログの場合: Ctl + D 、 Ctl + E :
1) Managed Debugging Assistants
の下のBindingFailureのチェックを外します2)共通言語ランタイム例外の下にあるSystem.IO.FileNotFoundExceptionのチェックを外します。
ああ、それはもっと良い:-)
...そして、この答えは1/2で、ストージャーによって10年11月24日10:12に与えられました