简体   繁体   English

无法在可移植类库中创建WCF通道

[英]Unable to create WCF channel in portable class library

I'm hoping I've just missed something obvious and someone will point it out to me here. 我希望我只是想念一些明显的东西,有人会在这里向我指出。

I've created a PCL that contains my WCF service as well as the DTOs that it uses. 我创建了一个PCL,其中包含我的WCF服务以及它使用的DTO。 The idea is to reference this on the server and implement the service, and also reference it on the client and use something like ChannelFactory<T> to create the channels and make the WCF calls. 想法是在服务器上引用此代码并实现服务,并在客户端上引用它,并使用ChannelFactory<T>来创建通道并进行WCF调用。

I can do this without a problem in a standard class library, but the PCL has a limited subset of the classes available, and most of the classes I've tried to use are abstract. 我可以在标准类库中毫无问题地做到这一点,但是PCL具有可用类的有限子集,而且我尝试使用的大多数类都是抽象类。

Can someone please help me? 有人可以帮帮我吗? Thanks 谢谢

ChannelFactory<T> is not available in the PCL when you're targeting Windows 8 (WinRT) or Silverlight for that matter. 当您将Windows 8(WinRT)或Silverlight定位为PC时, ChannelFactory<T>在PCL中不可用。 Everything is assumed to be done with ClientBase<T> . 假定一切ClientBase<T> This does suck as it creates a lot of ceremony around things, but if you use the "Service Reference" feature in Visual Studio (svcutil.exe on command line) it will generate the necessary plumbing for you. 这确实很麻烦,因为它引起了很多事情,但是,如果您使用Visual Studio中的“服务引用”功能(命令行上的svcutil.exe),它将为您生成必要的管道。

Note that if you were able to drop Silverlight and also go with Windows 8.1 compatibility you will get ChannelFactory<T> back. 请注意,如果您能够删除Silverlight并与Windows 8.1兼容,那么您将获得ChannelFactory<T>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM