gpt4 book ai didi

asp.net - 生成 Web 用户控件的 dll

转载 作者:行者123 更新时间:2023-12-01 23:13:58 24 4
gpt4 key购买 nike

如何制作我的 Web 应用程序用户控件的 dll?我有 usercontrol222.ascx,但我想用这个用户控件制作一个 dll。

最佳答案

创建一个仅包含用户控件(“usercontrol222.ascx”)的项目,并从新项目的部署中获取该控件的 dll。以下是此方法的来源以及更完整的解释:Turning an .ascx User Control into a Redistributable Custom Control (下面是值得注意的摘录,请参阅完整的链接)。

Step 3: Use the Publish Command to Precompile the Site

The next step is to use the newPublish command to precompile yoursite and turn your user control into apotential custom control. You'll findthe command under Build / Publish WebSite. In the Publish dialog, do thefollowing:

  • Pick a Target Location. This is the location on your hard drive that yoursite will be precompiled to.
  • Deselect "Allow this precompiled site to be updatable". In updatablemode, only the code behind file (ifany) would get compiled, and the ascxwould be left unprocessed. This isuseful in some scenarios, but is notwhat you want here since you want theresulting DLL to be self-contained.
  • Select "Use fixed naming and single page assemblies". This will guaranteethat your user control will becompiled into a single assembly thatwill have a name based on the ascxfile. If you don't check this option,your user control could be compiledtogether with other pages and usercontrols (if you had some), and theassembly would receive a random namethat would be more difficult to workwith.

Step 4: Finding the Resulting Custom Control

Now, using the WindowsExplorer or a command-line window,let's go to the directory youspecified as the target so we can seewhat was generated. You will see anumber of files there, but let's focuson the one that is relevant to ourgoal of turning the user control intoa custom control.

In the "bin" directory, you will finda file named something likeApp_Web_MyTestUC.ascx.cdcab7d2.dll.You are basically done, as this fileis your user control transformed intoa custom control! The only thingthat's left to do is to actually useit.

关于asp.net - 生成 Web 用户控件的 dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4391212/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com