在Silverlight中添加引用问题:您不能添加对dll的引用,因为它不是针对Silverlight运行时构建的 [英] Add reference problem in silverlight: You can't add a reference to dll as it was not built against the silverlight runtime

查看:78
本文介绍了在Silverlight中添加引用问题:您不能添加对dll的引用,因为它不是针对Silverlight运行时构建的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Silverlight应用程序,其中包含一个类库项目.类库在.Net framework 4中运行,silverlight项目在silverlight 3中运行.当我想在Silverlight项目中向类库添加引用时,我得到以下消息:

I have a silverlight application which has a class library project in it. th class library is running in .Net framework 4 and the silverlight project is running in silverlight 3. when I want to add a reference in the silverlight proj to the class library I get this message:

您不能添加对Classlibrary1.dll的引用,因为它不是针对silverlight运行时构建的.silverlight项目仅适用于silverlight组件."

"You can't add a reference to Classlibrary1.dll as it was not built against the silverlight runtime. silverlight project will only work with silverlight asseblies."

我试图将classlibrary1所使用的框架更改为.net Framework 3.5、3和2,但这无济于事. (而且我的silverlight应用程序只能在silverlight 3中运行)

I've tried to change the framework the classlibrary1 used to .net framework 3.5, 3, and 2 but it does not help. ( and my silverlight application can only run in silverlight 3)

推荐答案

显然, Silverlight项目仅适用于Silverlight组件. .NET和Silverlight的CLR不同,因此程序集不兼容.这些框架提供了不同的类集,程序集具有不同的版本,等等.

Apparently Silverlight project will only work with Silverlight asseblies. CLRs for .NET and Silverlight are different, therefore assemblies are not compatible. These frameworks provide different set of classes, assemblies have different versions, et cetera.

您需要将您的类库更改为 Silverlight类库.
可以通过手动更改项目文件来完成或通过创建 Silverlight类库项目,然后在其中复制源代码.如果非Silverlight项目需要相同的库,并且不想维护两个版本,请考虑使用添加现有项... 对话框的添加为链接功能仅引用原始资源而不复制原始资源.但是,您需要确保仅使用两个平台上都可用的功能来构建两个库版本.

You need to change your Class Library to Silverlight Class Library.
This can either be done by changing project file manually or by creating Silverlight Class Library project and copying the sources in it. If you need the same library for a non-Silverlight project and don't want to maintain two versions, consider using Add as Link feature of Add Existing Item... dialog to only reference the original sources without copying them. But you'll need to make sure you only use functionality available on both platforms for both library versions to build.

这篇关于在Silverlight中添加引用问题:您不能添加对dll的引用,因为它不是针对Silverlight运行时构建的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆