.NET 远程处理、版本控制和接口

发布于 2024-07-13 09:16:54 字数 391 浏览 3 评论 0原文

我有一个使用 2.0 框架的大型 .NET 远程处理项目。 服务器的 API 通过接口公开,共享类型包含在与客户端应用程序共享的程序集中。

我有一些方法接受基类的数组,该基类有许多不同的类继承自它。

例如,我有一个基类“Vehicle”,它有两个继承自它的类“Car”和“Truck”。

我有一个方法 IFoo.Save(List cars)

后来我添加了一个继承自“Vehicle”的新类,名为“Motorcycle”,并且只有服务器或客户端拥有新的共享程序集,但两者都没有。 其中之一将无法解析新类型。

您认为处理这种情况最灵活的方法是什么?

编辑:这是一个 Windows 窗体客户端应用程序和托管在 Windows 服务中的远程服务器。

I have a large .NET remoting project using the 2.0 framework. The server's API is exposed via interfaces and shared types are contained in an assembly shared with the client application.

I have some methods that accept arrays of a base class that has many different classes inheriting from it.

For example I have base class "Vehicle" that has two classes that inherit from it say "Car" and "Truck".

I have a method IFoo.Save(List vehicles)

Later on I add a new class that inherits from "Vehicle" named "Motorcycle", and only the server or client has the new shared assembly but not both. One of them won't be able to resolve the new type.

What do you feel is the most flexible way to handle this situation?

EDIT: This is a Windows forms client application and remoting server hosted in a Windows service.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

后eg是否自 2024-07-20 09:16:56

ClickOnce 是一个很好的解决方案。

或者采用与类无关的 Web 服务方法。 传递可以重构为对象的版本化、二进制流字典。 如果它很重要,请编写对象重构内容来处理向前和向后兼容性,否则就拒绝具有“未来”版本号的数据。

Web 服务非常适合解耦。 字典非常适​​合传递一般数据。 基于程序集的类版本控制是可怕的(即使最近版本的 .Net 中的序列化发生了变化)并且会导致疯狂......

ClickOnce is a good solution.

Or go with a class-agnostic Web Services approach. Pass around versioned, binary-streamed dictionaries that can be reconstituted as objects. If it is important, write your object reconstitution stuff to handle both forward- and backward-compatibility, otherwise just reject data with a "future" version number.

Web services are great for decoupling. Dictionaries are great for passing general data. Assembly-based class versioning is horrible (even with the Serialization changes in recent versions of .Net) and leads to madness...

燕归巢 2024-07-20 09:16:56

发布更新。 对于这样的事情,你必须始终将所有内容都放在同一版本上。 也许可以考虑 ClickOnce 让每个人都了解最新情况。

Publish an update. For things like this you always have to have everything on the same version. Maybe consider ClickOnce to keep everyone up to date.

南风起 2024-07-20 09:16:56

这看起来更像是一个部署问题。 服务器和客户端必须有权访问相同版本的共享程序集。 您的策略将取决于平台 - 是网络还是表单?

实现此目的的一种方法是强制客户端使用共享程序集的特定版本,并向客户端提供该程序集的交付方法。

This seems like more of a deployment question. Server and client must have access to the same version of the shared assembly. Your strategy will depend on platform- is this web or forms?

One way to do this is to force clients to use a specific version of the shared assembly and provide a delivery method for that assembly to clients.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文