多个 ASP.Net 应用程序使用的通用代码

发布于 2024-07-09 20:08:41 字数 225 浏览 5 评论 0原文

场景:

假设我有四个非常相似的应用程序(即大部分功能是相同的,但它们的不同足以证明每个应用程序都是单独的应用程序)。

重用它们之间的通用功能代码的最佳方法是什么? COM+? 网页服务?

一般来说,我通常只是将代码放在一个单独的项目 (dll) 中,但每当更新时,都必须为每个 ASP.Net 应用程序更新该文件,并且不确定是否有更好的方法它。

谢谢!

Scenario:

Let's say I have four very similar applications (i.e. most of the functionality is the same, but they are different enough to justify each being seperate applications).

What is the best way to re-use the common functionality code between them? COM+? Web services?

In general I'd typically just have the code in a seperate project (dll), but anytime that's updated, the file has to be updated for each ASP.Net application, and wasn't sure if there was a better way of going about it.

Thanks!

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

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

发布评论

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

评论(3

山色无中 2024-07-16 20:08:41

如果可能,您可以使用 DLL 项目和多个 Web 应用程序或网站项目创建 Visual Studio 解决方案。 Web 项目将具有对 DLL 项目的“项目”类型引用,并且所有内容都会同时构建。 然后,您可以根据需要对每个 Web 项目使用“发布”工具。

If possible, you can create a Visual Studio solution with a DLL Project and a number of Web Application or Website projects. The web projects would have a "project" type reference to the DLL project, and everything would build at the same time. Then you could use the "Publish" tool for each of your web projects as needed.

星星的軌跡 2024-07-16 20:08:41

如果所有应用程序都位于同一虚拟服务器上,请考虑将共享程序集放置在 GAC 中。 这允许您在需要时使用不同的版本,并将所有内容保留在同一个地方作为奖励。 缺点:此程序集在完全信任的情况下运行,您应该使用策略和 CAS 来确保外部不受信任的程序集的信任杠杆点不会升高。 您还需要了解 [AllowPartiallyTrustedCallers] 属性。

至于其他选择,COM+,嗯,有点重量级。 适合交易的东西。 Web 服务对于数据密集型服务来说不太好,但如果做得好,可以相当容易维护。 分享越多,回报就越好。

If all the apps are on the same virtual server, consider placing the shared assembly in the GAC. This allows you to diverge versions should the need arise, and keeps everything in the same place as a bonus. Downsides: this assembly runs with full trust and you should use policy and CAS to ensure there are no elevation of trust leverage points for external untrusted assemblies. You'll also need to learn about the [AllowPartiallyTrustedCallers] attribute.

As for the other choices, COM+, meh, a bit heavyweight. Good for transactional stuff. Web services, not so good for data heavy services, but if done right, can be fairly maintainable. The more it's shared, the better the pay off.

冬天旳寂寞 2024-07-16 20:08:41

您可以拥有自己的项目,但不要将公共 dll 添加到项目引用中,而是将公共项目添加到所有解决方案中,然后添加对公共项目的引用。

通过这种方式,您可以在一个项目上使用任意数量的解决方案,并且您的问题得到解决;)

You can have your project, but instead of adding the common dll to the project reference add the common project to all solutions and then add a reference to the common project.

This way you can have one project on any number of solutions and you have your problem solved ;)

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