本文介绍了Silverlight 4的组件共享问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF的.NET 4.0类库引用的Silverlight 4类库。

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

的SL库编译罚款,但是当我编译WPF类库,我得到:

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

我想,这个问题必须类似于在这里提到的: http://markti.spaces.live.com/blog/cns!D92CF278F0F91957 !273.entry

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

但我的WPF库不包含引用从我的SL库中的用户控件的任何XAML。事实上,我的SL库不具有任何XAML的。它,然而,有几个共同DependencyObjects,如EventCommander(绑定UI元素的事件命令),以及一些DataTemplate中的助手。

but my WPF library doesn't contain any XAML that references a user control from my SL library. In fact, my SL library doesn't have any XAML in it at all. It does, however, have several shared DependencyObjects, such as an EventCommander (binding UI element events to Commands), and some DataTemplate helpers.

有什么办法,我可以在这里缩小问题?而有没有人发现,从.NET 4.0中有效地引用UI元素在SL4项目的方式?

Is there any way I can narrow down the problem here? And has anyone found a way of effectively referencing UI elements in a SL4 project from .NET 4.0?

感谢。

推荐答案

没有人知道的一种方式来引用SL4组件从一个完整的.NET程序集System.Windows引用(不只是链接文件并创建两个不同的项目保持)?

是不可能的时刻。在.NET项目引用SL装配只会工作​​,如果SL项目不引用以外的任何组件的 mscorlib程序,系统,System.Core程序,System.ComponentModel.Composition Microsoft.VisualBasic程序。添加一个WPF项目和链接SL文件到该项目是可以重用你的SL code。如果它使用如的唯一途径System.Windows。

is not possible at the moment. Referencing SL assemblies in .NET projects will only work if the SL project does not reference any assemblies other than mscorlib, System, System.Core, System.ComponentModel.Composition and Microsoft.VisualBasic.Adding a WPF project and linking your SL files into that project is the only way you can reuse your SL code if it uses e.g. System.Windows.

干杯,亚历克斯

这篇关于Silverlight 4的组件共享问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 04:35