以编程方式添加@Assembly引用 [英] Adding @Assembly references programmatically

查看:100
本文介绍了以编程方式添加@Assembly引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




有没有办法在自定义控件中以编程方式将@Assembly引用添加到aspx文件中

(当它被删除时)从工具箱中获取
页面?


我有一个自定义控件 - MyControl在另一个实现接口

自定义程序集 - InterfaceAssembly。当MyControl被放到

页面并运行时,它会导致找不到InterfaceAssembly。例外。我知道这可以通过手动添加@Assembly指令来修复

引用GAC中的InterfaceAssembly(或者在
中添加对它的引用)
web.config / machine.config等) - 但这还不够好。

MyControl是一个控件,将分发给很多人和

我们不希望他们每次拖放时都做这个手动步骤/>
这个控制到一个页面 - 不是很优雅。


我看到来自MS的Steven Cheng已回复了
$ b $中的一些相关问题b新闻组。希望收到他或MS的其他人的来信。


提前致谢,

Praveen

Hi,

Is there any way to add the @Assembly reference to the aspx files
programmatically from inside a custom control (when it gets dropped on to
the page from the toolbox)?

I have a custom control - MyControl that implements an interface in another
custom assembly - InterfaceAssembly. When MyControl gets dropped on to the
page and run, it results in a "InterfaceAssembly not found" exception. I am
aware that this can be fixed by manually adding a @Assembly directive
refering to the InterfaceAssembly in the GAC (or add a reference to it in
the web.config/machine.config, etc) - but that is not good enough. The
MyControl is a control that will be distributed to a whole lot of people and
we do not want them to do this manual step every time they drag and drop
this control to a page - not very elegant.

I see that Steven Cheng from MS has responded to some related issues in the
newsgroups. Hope to hear from him or someone else from MS.

Thanks in advance,
Praveen

推荐答案

如果它是用户控件,那么您可以将@Assembly指令添加到ASCX

文件中。如果它是自定义控件,则通过

项目引用添加对程序集的引用,然后编译项目。如果它在App_Code

目录中,则通过web.config添加程序集引用:

http://msdn.microsoft.com/library /de...asp?frame=true


-Brock

DevelopMentor
http://staff.develop.com/ballen
If it''s a user control, then you can add the @Assembly directive to the ASCX
file. If it''s a custom control, then add the reference to the assembly via
project references and then compiling your project. If it''s in the App_Code
directory, then add an assembly reference via web.config:

http://msdn.microsoft.com/library/de...asp?frame=true

-Brock
DevelopMentor
http://staff.develop.com/ballen

我有一个自定义控件 - MyControl,它在另一个自定义程序集中实现了一个接口 - InterfaceAssembly。当MyControl被放到页面上并运行时,它会导致InterfaceAssembly not
found。例外。我知道这可以通过手动添加引用GAC中的InterfaceAssembly的@Assembly指令来修复(或者在web.config / machine.config中添加对它的引用等) - 但是
还不够好。 MyControl是一个控件,将分发给很多人,我们不希望他们每次将这个控件拖放到页面时都要执行这个手动步骤
- 不是很优雅。

我看到来自MS的Steven Cheng对新闻组中的一些相关问题做出了回应。希望收到他或MS的其他人的来信。

提前致谢,
Praveen
Hi,

Is there any way to add the @Assembly reference to the aspx files
programmatically from inside a custom control (when it gets dropped on
to the page from the toolbox)?

I have a custom control - MyControl that implements an interface in
another custom assembly - InterfaceAssembly. When MyControl gets
dropped on to the page and run, it results in a "InterfaceAssembly not
found" exception. I am aware that this can be fixed by manually adding
a @Assembly directive refering to the InterfaceAssembly in the GAC (or
add a reference to it in the web.config/machine.config, etc) - but
that is not good enough. The MyControl is a control that will be
distributed to a whole lot of people and we do not want them to do
this manual step every time they drag and drop this control to a page
- not very elegant.

I see that Steven Cheng from MS has responded to some related issues
in the newsgroups. Hope to hear from him or someone else from MS.

Thanks in advance,
Praveen






如果它是用户控件,则可以将@Assembly指令添加到ASCX

文件中。如果它是自定义控件,则通过

项目引用添加对程序集的引用,然后编译项目。如果它在App_Code

目录中,则通过web.config添加程序集引用:

http://msdn.microsoft.com/library /de...asp?frame=true


-Brock

DevelopMentor
http://staff.develop.com/ballen
If it''s a user control, then you can add the @Assembly directive to the ASCX
file. If it''s a custom control, then add the reference to the assembly via
project references and then compiling your project. If it''s in the App_Code
directory, then add an assembly reference via web.config:

http://msdn.microsoft.com/library/de...asp?frame=true

-Brock
DevelopMentor
http://staff.develop.com/ballen

我有一个自定义控件 - MyControl,它在另一个自定义程序集中实现了一个接口 - InterfaceAssembly。当MyControl被放到页面上并运行时,它会导致InterfaceAssembly not
found。例外。我知道这可以通过手动添加引用GAC中的InterfaceAssembly的@Assembly指令来修复(或者在web.config / machine.config中添加对它的引用等) - 但是
还不够好。 MyControl是一个控件,将分发给很多人,我们不希望他们每次将这个控件拖放到页面时都要执行这个手动步骤
- 不是很优雅。

我看到来自MS的Steven Cheng对新闻组中的一些相关问题做出了回应。希望收到他或MS的其他人的来信。

提前致谢,
Praveen
Hi,

Is there any way to add the @Assembly reference to the aspx files
programmatically from inside a custom control (when it gets dropped on
to the page from the toolbox)?

I have a custom control - MyControl that implements an interface in
another custom assembly - InterfaceAssembly. When MyControl gets
dropped on to the page and run, it results in a "InterfaceAssembly not
found" exception. I am aware that this can be fixed by manually adding
a @Assembly directive refering to the InterfaceAssembly in the GAC (or
add a reference to it in the web.config/machine.config, etc) - but
that is not good enough. The MyControl is a control that will be
distributed to a whole lot of people and we do not want them to do
this manual step every time they drag and drop this control to a page
- not very elegant.

I see that Steven Cheng from MS has responded to some related issues
in the newsgroups. Hope to hear from him or someone else from MS.

Thanks in advance,
Praveen






Brock,


感谢您的回复。但是,就像我提到的那样,我不想手动添加

引用,我希望我的自定义控件将这个自动插入

到添加它的aspx文件中,如果可能的话。


谢谢

-Praveen
Brock,

Thanks for the reply. But, like I mentioned I do not want to add the
reference manually, I want my custom control to INSERT this AUTOMATICALLY
into the aspx file in which it was added, if possible.

Thanks
-Praveen


这篇关于以编程方式添加@Assembly引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆