Silverlight 4 sharing issue

I have a WPF.NET 4.0 class library referencing a Silverlight 4 class library.

The SL library compiles fine, but 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.Presentation.Wpf 

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

but my WPF library does not contain XAML, which refers to a user control from my SL library. In fact, my SL library does not have XAML at all. However, it has several common DependencyObjects objects, such as EventCommander (binding events of the UI element to commands) and some DataTemplate helpers.

Can I narrow down the problem here? And has anyone found a way to efficiently reference user interface elements in an SL4 project with .NET 4.0?

Thanks.

+4
source share
3 answers

this is

Does anyone know a way to reference the SL4 assembly with System.Windows references from the complete .NET assembly (without just linking to files and creating two different projects for support)?

impossible at the moment. The reference to SL assemblies in .NET projects will work only if the SL project does not refer to any assemblies, except mscorlib, System, System.Core, System.ComponentModel.Composition and Microsoft.VisualBasic. Adding a WPF project and linking your SL files to this project is the only way to reuse your SL code if it uses, for example. System.Windows.

Cheers, Alex

+4
source

Maybe I'm late, but they haven't answered that yet.

VisualStudio 2010 has a plugin that allows you to create assemblies that can be referenced in .NET, Silverlight, Windows Phone, and XNA on xbox. It was called PortableLibrary.

http://blogs.msdn.com/b/bclteam/archive/2011/01/19/announcing-portable-library-tools-ctp-justin-van-patten.aspx

+2
source

Found! I had several xmlns namespaces defined in my SL4 class library, for example:

 using System.Windows.Markup; [assembly: XmlnsDefinition("http://MyProj/Presentation", "MyProj.Presentation")] [assembly: XmlnsDefinition("http://MyProj/Presentation", "MyProj.Presentation.Controls")] 

and this prevented the WPF assembly from referencing it, causing the above error. Just moved the namespace declarations to the WPF project to fix ...

[change]

So this fixed the problem ... but does anyone know how to reference the SL4 assembly with System.Windows references from the complete .NET assembly (without just linking the files and creating two different projects for support)

0
source

Source: https://habr.com/ru/post/1311971/


All Articles