类库,Silverlight和Web服务 [英] Class Libraries, Silverlight and Webservices

查看:112
本文介绍了类库,Silverlight和Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Silverlight类库,我想在我的两个Silverlight和我的web项目中使用。

I have a Silverlight Class Library that I want to use in both my Silverlight and my WebService project.

我能够创建和引用库中的两个项目没有任何问题,但是当我尝试在Silerlight项目中使用的任何类的图书馆,我的图书馆和ASMX web服务之间的暧昧引用错误(显然,Silverlight项目认为,类类库中的Web服务存在的话)。

I am able to create and reference the Library in both projects without any problems, but when I try to use any of the classes in the Library on the Silerlight project, I get an ambiguous reference error between my Library and the Asmx Webservice (apparently, the silverlight project believes that the classes in the class library exist in the webservice).

我怎样才能解决这个问题呢?我曾试图重建和清理,但它似乎并没有工作。任何人都可以帮忙吗?

How can I correct this issue? I have tried rebuilding and cleaning, but it does not seem to work. Can anyone help?

推荐答案

听起来像是要传递到Silverlight的对象,通过WCF服务,在你的类库相同的对象。在这种情况下,所产生的网络的参考对象将被给予相同的名称。与库链接将然后给你2台具有相同名称的对象。

Sounds like the objects you are passing to Silverlight, via the WCF service, are the same objects in your class library. In that case the generated web-reference objects will be given the same names. Linking with the library will then give you 2 sets of objects with the same names.

如果您安装RIA服务,一旦特点是通过简单地添加.shared在扩展前的类名来分享客户端和服务器之间的code的能力。 ASMX服务的所以上世纪的:)

If you install RIA services, once feature is the ability to share code between client and server by simply adding ".shared" in the class filenames before the extensions. ASMX services are so last century :)

如果你不想学的整个的大-网络鸿沟共享对象的RIA服务方式的(我会推荐),您需要从功能分离的数据对象,你其实要共享客户端和服务器端。

if you don't want to learn the RIA services way of sharing objects across the great-web-divide (which I would recommend), you need to separate the data objects from the functionality you actually want to share client and server side.

要对你目前的设置给出更具体的意见,我需要看到更多关于它的结构。

To give more specific advice on your current set-up I would need to see more about how it is structured.

这篇关于类库,Silverlight和Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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