.NET 2.0 项目的问题,使用实现 WCF 服务的 3.0 DLL
我在一个项目中创建了一个用于访问我的 WCF 服务的客户端,所有与服务一起使用的类都继承自该类:
public abstract class ServiceClient<TServiceClient> : IDisposable where TServiceClient : ICommunicationObject
该类是我执行诸如处置、调用客户端时记录等操作的地方。课程通常会做。
一切都工作正常,直到我接到在旧系统上实现这一点的任务。当我在另一个无法引用 System.ServiceModel 的项目中使用此项目(DLL)时,我遇到了问题(因为它是我仍在维护的旧 .NET 2.0 软件,将其升级到 3.0 是不可能)。在这里,如果我省略 where TServiceClient : ICommunicationObject
那么项目可以构建,但 ServiceClient
无法使用,例如 client.Close()
或者 client.State
那么,我唯一的解决方案是删除 where
语句并重写服务类吗?
I made a client for accessing my WCF services in one project, and all classes that work with services inherit from this class:
public abstract class ServiceClient<TServiceClient> : IDisposable where TServiceClient : ICommunicationObject
This class is where I do stuff like disposing, logging when the client was called, etc. some common stuff which all service classes would normally do.
Everything worked fine, until I got the task to implement this on an old system. I got into a problem when I used this project (DLL) in an other project which cannot reference System.ServiceModel
(since it's an old .NET 2.0 software that I still maintain, and upgrading it to 3.0 is out of the question). Here, if I omit where TServiceClient : ICommunicationObject
then the project can build, but the ServiceClient
cannot use, for example, client.Close()
or client.State
So, is my only solution to drop the where
statement, and rewrite the service classes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您无法将该项目升级到 3.0,那么这个(或包装类)似乎是您唯一的选择。
If you can't upgrade that project to 3.0, this (or a wrapper class) seems to be your only option.
是什么阻止你升级? 3.0 并不是真正的新版本框架,它只是一些额外的 dll。您的 2.0 代码将像以前一样使用相同的 .net 库运行。
What is stopping you upgrading? 3.0 is not really a new version of the framework, it is just some additional dll's. Your 2.0 code will run as before using the same .net libraries.