具有共享模型的客户端/服务器项目的最佳 Visual Studio 解决方案/项目结构

发布于 2024-09-07 01:55:49 字数 390 浏览 4 评论 0原文

我很好奇在解决方案和项目中(使用 Visual Studio 和 C#)构建具有可执行客户端程序、可执行服务器程序和共享模型的应用程序的首选方式是什么。由于习惯了Java开发,我最初将项目视为包,并为我设计的每个包定义了一个项目。

这导致了一个包含六个项目的解决方案(一个用于模型,一个用于服务器,四个用于客户端),这反过来又导致了一些愚蠢的依赖关系,使我重新考虑这是否是最好的方法。

现在,我计划将解决方案重组为总共三个项目:客户端项目、服务器项目和模型项目。客户端和服务器都将依赖于模型项目(其中我还将添加客户端和服务器之间的共享接口)。

这是构建此类应用程序的最佳方式吗?

另外,在 Visual Studio 的树结构中反映命名空间的最佳方式是什么? (例如,只是创建一个类似的文件夹结构?)。

I am curious what the preferred way to structure an application with an executable client program, an executable server program and a shared model in solutions and projects (using Visual Studio and C#). Being used to Java development I initially regarded projects as packages and defined a project for each package I designed.

This resulted in a six-project solution (one for the model, one for the server and four for the client) which in turn resulted in some silly dependencies causing me to reconsider if this is the best approach.

Now, I am planning to restructure the solution to three projects total: a client project, a sever project and a model project. Both the client and the server will be dependent on the model project (in which I will also add the shared interface between client and sever).

Is this the best way to structure such an application?

Also, what is the best way to reflect namespaces within the tree structure of Visual Studio? (Just creating a similar folder structure for instance?).

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

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

发布评论

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

评论(1

总以为 2024-09-14 01:55:49

3 项目解决方案(客户端/服务器/模型)确实是您的场景的标准。

关于命名空间:是的,您的文件夹结构应该反映您正在使用的命名空间。可以在项目属性中设置默认命名空间,文件夹名称将添加到该命名空间。

A 3-project solution (client / server / model) is indeed the norm for your scenario.

Regarding namespaces: Yes, your folder structure should reflect the namespaces you are using. The default namespace can be set in the project properties, folder names are added to that namespace.

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