生成一个Web用户控件的一个dll [英] generating a dll of a web usercontrol
问题描述
我怎样才能让我的web应用程序用户控件的一个dll?
我有usercontrol222.ascx,但我想打一个dll出这个用户控件的。
How can I make a dll of my web application usercontrol? I have usercontrol222.ascx, but I want to make a dll out of this usercontrol.
推荐答案
创建只包含用户控件(usercontrol222.ascx)项目和新项目的部署抢控件的DLL。下面是该方法的一个更完整的解释来源:打开一个的.ascx用户控件成可再发行自定义控件(以下摘录显着,看到该链接为全面破败)。
Create a project containing only your user control ("usercontrol222.ascx") and grab the control's dll from the deployment of your new project. Here's the source of this method with a more complete explanation: Turning an .ascx User Control into a Redistributable Custom Control (Notable excerpts below, see the link for the full run-down).
下一步是使用新的
发布命令precompile您
网站,把你的用户控件成
潜在的自定义控件。你会找到
在构建命令/发布Web
现场。在发布对话框中,执行
以下内容:
Step 3: Use the Publish Command to Precompile the Site
The next step is to use the new Publish command to precompile your site and turn your user control into a potential custom control. You'll find the command under Build / Publish Web Site. In the Publish dialog, do the following:
- 选择一个目标位置。这是你的硬盘上的位置,你的
网站将pcompiled至$ P $。 - 取消选择允许这台precompiled网站是更新。在可更新
模式下,仅落后文件code(如果
任)将被编译,而ASCX
将留待未处理。这是
在某些情况下是有用的,但并不
因为你想要的,你想要的这里
结果DLL是自包含的。 - 选择使用固定命名和单页组件。这将保证
您的用户控制将是
编译成一个大会,
基于所述的ascx将有一个名称
文件。如果不选中此选项,
用户控件可以被编译
与其他页面和用户一起
对照组(如果有一些),且
大会将收到一个随机名称
这将是比较困难的工作
用。
现在,使用Windows
资源管理器或命令行窗口,
让我们去的目录,你
指定为目标,所以我们可以看到
生成的内容。你会看到一个
文件中有一些,但我们的重点
上一个是与我们的
旋转使用者控制成目标
一个自定义的控制。
Now, using the Windows Explorer or a command-line window, let's go to the directory you specified as the target so we can see what was generated. You will see a number of files there, but let's focus on the one that is relevant to our goal of turning the user control into a custom control.
在bin目录,你会发现
一个类似的文件命名
App_Web_MyTestUC.ascx.cdcab7d2.dll。
你基本上是做了,因为这个文件
在用户控件转变成
一个自定义的控制!唯一的事情
现在剩下要做的就是实际使用
吧。
In the "bin" directory, you will find a file named something like App_Web_MyTestUC.ascx.cdcab7d2.dll. You are basically done, as this file is your user control transformed into a custom control! The only thing that's left to do is to actually use it.
这篇关于生成一个Web用户控件的一个dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!