ASP.NET 预编译无法合并单个用户控件

发布于 2024-08-13 06:12:29 字数 370 浏览 1 评论 0原文

我有一个相当大的第三方 ASP.NET 网站项目,我使用 MSBuild 和 Microsoft Web 部署目标对其进行预编译和合并。我不预编译 .aspx 和 .ascx 文件,仅预编译代码文件。

在预编译阶段,用户控件被编译成一个程序集,该程序集不会合并到最终的 WebSite.dll 程序集中。最终输出包含:

  • WebSite.dll
  • App_Web_selectsinglepath.ascx.73690ebc.dll

所有其他用户控件都被编译成名称如 App_Web_abcdefgh.dll 的程序集,并且这些程序集被合并到 WebSIte.dll 中,只有这个控件没有。

造成这种行为的原因是什么?

I have rather large third party ASP.NET WebSite project that I precompile and merge using MSBuild and the Microsoft Web Deployment targets. I don't precompile the .aspx and .ascx files, only the codefiles.

During the precompilation phase, the user control is compiled into an assembly that is not merged into the final WebSite.dll assembly. The final output contains:

  • WebSite.dll
  • App_Web_selectsinglepath.ascx.73690ebc.dll

All other user controls were compiled into assemblies with names like App_Web_abcdefgh.dll and these assemblies were merged into WebSIte.dll, just this one control was not.

What could be the cause of this behavior?

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

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

发布评论

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

评论(2

不美如何 2024-08-20 06:12:29

我在尝试从 Web 应用程序项目的命令行使用 aspnet_compileaspnet_merge 时遇到了类似的问题。两个控件始终具有命名程序集而不是 App_Web_[hex].dll,然后在合并后将无法加载。

就我而言,我能够将 -fixednames 标志添加到 aspnet_compile 调用中,该调用生成所有控件库作为 App_Web_[control_name].[hex] .dll,这使得它们对 aspnet_merge 可见,从而消除了程序集加载错误。

我仍然不明白为什么这些控件会始终使用不同的文件名模式生成(层次结构中没有重复的页面或控件名称),但是有人。

I had a similar issue trying to use aspnet_compile and aspnet_merge from the command line for a Web App project. Two controls would always have named assemblies instead of App_Web_[hex].dll, then would fail to load after the merge.

In my case I was able to add the -fixednames flag to the aspnet_compile call, which generated all of the control libraries as App_Web_[control_name].[hex].dll, which made them all visible to aspnet_merge, which removed the assembly loading error.

I still don't understand why those controls would consistently be generated with a different file name pattern (no duplicate page or control names in the hierarchy), but HTH someone.

蓝颜夕 2024-08-20 06:12:29

用户控件被编译成单独的程序集,因为这允许您将用户控件视为 Web 控件。您可以使用 ILMerge 实用程序将多个程序集合并为一个程序集。这是一个很好的页面解释了这一点。

User controls are compiled into separate assemblies because this allows you to treat your user controls as web controls. You can use ILMerge utility to merge multiple assemblies into one. Here is a good page explaining this.

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