在同一项目 Visual Studio.NET 中构建单独的程序集

发布于 2024-09-16 14:58:52 字数 313 浏览 5 评论 0 原文

我在网上搜索了这个问题的答案,但没有运气。

我想知道是否可以构建某些类和/或 .cs 文件来分离同一项目中的程序集?

即,我在一个项目中有多个 HttpHandler,目前我正在将它们全部构建到一个程序集 HttpHandler 中,但我在想如果以后我想更改其中一个处理程序中的代码,我将需要重建整个程序集,并且即使我没有更改代码,也可能会给其他处理程序带来问题。我认为最好让它们保持自治,这样对一个处理程序的更新绝不会影响其他处理程序。当然,我可以创建单独的项目,但我想知道是否可以在同一个项目中执行此操作。

我用的是VS2008专业版。

谢谢!

I've searched online for the answer to this but with no luck.

I was wondering if it was possible to build certain classes and or .cs files to separate assemblies within the same project?

I.e I have a number of HttpHandlers in one project, currently I am building them all into one assembly HttpHandlers, but what I was thinking if later I wanted to change the code in one of the Handlers I would need to rebuild the whole assembly, and possibly introduce problems with the other Handlers even though I haven't changed the code. I thought it would be best to keep them autonomous so an update to one handler would in no way affect the others. Ofcourse I could create separate projects but I was wondering if it was possible to do this within the same project.

I'm using VS2008 Pro.

Thanks!

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

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

发布评论

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

评论(2

北音执念 2024-09-23 14:58:52

May be you can do that with Multi-file Assemblies. But it's a lot of work.

心碎的声音 2024-09-23 14:58:52

编辑我不小心发布了错误的问题(打开了多个选项卡 - 我的错)。该解决方案针对相反的问题:如何将多个程序集合并为一个 .exe

我今天研究了同样的问题,发现 ILMerge

我有一个简单的 WinForms 应用程序,只是想快速查看一些内容。
以下是我在主项目 bin\Debug 目录中运行的内容:

"C:\Program Files (x86)\Microsoft\ILMerge\ILMerge.exe"
  /targetplatform:v4,"%ProgramFiles(x86)%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5"
  /target:winexe /wildcards /out:TheNewMerged.exe TheOld.exe *.dll

copy TheOld.exe.config TheNewMerged.exe.config

“/targetplatform”开关用于修复 ILMerge 抛出“不允许未解析的程序集引用:System.Core”异常的问题。

我的项目是用 v4.5 编译的 - 为您的项目调整它。

其他人建议通过创建 ILMerge.exe.config 文件来解决该问题。
它肯定会使命令行更短:-)

EDIT: I accidentally posted to the wrong question (multiple tabs opened - my bad). This solution is for the opposite problem: how to merge multiple assemblies into one single .exe.

I looked into the same issue today and found ILMerge from MS Research.

I had a simple WinForms app and just wanted to see something quickly.
Here is what I ran in my main projects bin\Debug directory:

"C:\Program Files (x86)\Microsoft\ILMerge\ILMerge.exe"
  /targetplatform:v4,"%ProgramFiles(x86)%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5"
  /target:winexe /wildcards /out:TheNewMerged.exe TheOld.exe *.dll

copy TheOld.exe.config TheNewMerged.exe.config

The "/targetplatform" switch is to fix an issue with ILMerge throwing an "Unresolved assembly reference not allowed: System.Core" exception.

My project was compiled with v4.5 - adjust this for your project.

Other people have suggested fixing the issue by creating an ILMerge.exe.config file.
It will certainly make the command-line shorter :-)

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