Reputation: 65
Why getting this error ?
Error 12 Unknown build error,
'Cannot resolve dependency to assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'
because it has not been preloaded. When using the ReflectionOnly APIs,
dependent assemblies must be pre-loaded or loaded on demand through the
ReflectionOnlyAssemblyResolve event.' WpfApp
Upvotes: 4
Views: 11041
Reputation: 1206
This error means that one of the libraries you are using for your project depends itself on the .Net framework's System.Runtime.Serialization
assembly.
When you try to build your project it fails when it parses the XAML part that tries to load the library assembly (using reflection) but the .Net dependency hasn't been loaded yet (See also this answer).
The easiest way to resolve this is by adding the System.Runtime.Serialization
assembly directly to your wpf project references.
Upvotes: 8
Reputation: 2402
Pretty much what it says.
Looks like you are trying to deserialize an object but the DLL that one of the object's dependent objects relies on has not been loaded yet.
I had a similar issue using dependency injection in an asp.net app and the solution was to explicitly load all of the DLLs in my bin directory. In my case, I used the System.IO classes to get the list of files in the directory and then loaded each DLL explicitly.
See this question for how to load DLLs Loading DLLs at runtime in C#
Upvotes: 2