Silverlight 4 assembly sharing problem

I have a WPF .NET 4.0 class library that references the Silverlight 4 class library.

The SL library compiles well but when I compile the WPF class library When I get:

Error 2 Unknown build error,'Cannot resolve dependency to assembly'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' 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.' MyProj.Presentation.Wpf

I think the problem must be similar to the one mentioned here The question:
http://markti.spaces.live.com/blog/cns!D92CF278F0F91957!273.entry

But my WPF library does not contain any references to my SL library XAML for user controls. In fact, my SL library does not have any XAML at all. However, it does have several shared DependencyObjects, such as EventCommander (bind UI element events to Commands), and some DataTemplate helpers.

Is there any way to narrow down this problem? Has anyone found a way to effectively reference UI elements in SL4 projects from .NET 4.0?

Thank you.

this

does anyone know of a way to reference a SL4 assembly with System.Windows references from a full .NET assembly (without just linking the files and creating two different projects to maintain)?

It is currently not possible. Only when the SL project does not reference any assembly other than mscorlib, System, System.Core, System.ComponentModel.Composition and Microsoft.VisualBasic, it can be used in .NET The SL assembly is referenced in the project.
Adding a WPF project and linking the SL file to the project is the only way to reuse SL code, if it uses, for example, System.Windows.

Cheers, Alec Si

I have a WPF .NET 4.0 class library that references the Silverlight 4 class library.

The SL library compiles well but when When I compile the WPF class library, I get:

Error 2 Unknown build error,'Cannot resolve dependency to assembly'System.Windows, Version=2.0.5.0, Culture=neutral , PublicKeyToken=7cec85d7bea7798e' 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.' MyProj.P resentation.Wpf

I think the problem must be similar to the one mentioned here:
http://markti.spaces.live.com/blog/cns!D92CF278F0F91957!273.entry

But my WPF library does not contain any XAML that references user controls in my SL library. In fact, my SL library does not have any XAML at all. However, it does have several shared DependencyObjects, such as EventCommander (will UI element events are bound to Commands), and some DataTemplate helpers.

Is there any way to reduce this problem? Has anyone found a way to effectively reference UI elements in SL4 projects from .NET 4.0?

Thank you.

This

does anyone know of a way to reference a SL4 assembly with System.Windows references from a full .NET assembly (without just linking the files and creating two different projects to maintain)?

It is currently impossible The SL assembly can be referenced in the .NET project only if the SL project does not reference any assembly other than mscorlib, System, System.Core, System.ComponentModel.Composition and Microsoft.VisualBasic.
Add WPF Project and linking the SL file to the project is the only way to reuse the SL code if it uses e.g. System.Windows.

Cheers, Alex

Leave a Comment

Your email address will not be published.