大会圣人的一个有趣问题 [英] An interesting problem for Assembly sages

查看:82
本文介绍了大会圣人的一个有趣问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我可以使用Assembly.Load加载程序集(....)


然而,我'' d喜欢动态加载程序集与在VS2005项目中放置

程序集引用相同。是的,我知道

卸货问题。让我们说我现在不在乎。


如果我在c:\\assembly.dll中有一个可装配的文件。 - 如何在运行时将它加载到

运行时,就像它在构建时是项目中的引用一样?我知道

关于将程序集加载到当前appDomain中的事情但是不能
似乎能够找到如何做到这一点的示例。我对此的尝试有

失败。


帮助?


谢谢

Ron

Hi,

I can load an assembly using the Assembly.Load(....)

However, I''d like dynamic loading of assemblies to be identical to putting
an assembly reference in your VS2005 project. and yes, I know about the
unloading problems. Let''s say I don''t care for the moment.

If I have an assemlbly file at "c:\\assembly.dll" - how do I load it at
runtime as if it were references in the project at build time? I know
something about loading an assembly into the current appDomain but can''t
seem to be able to find examples on how to do that. My attemps on this have
failed.

Help?

Thanks
Ron

推荐答案

" Ron M. Newman"写道:
"Ron M. Newman" wrote:

我可以使用Assembly.Load(....)加载程序集


然而,我'我希望动态加载程序集与在VS2005项目中放置

程序集引用相同。是的,我知道

卸货问题。让我们说我现在不在乎。


如果我在c:\\assembly.dll中有一个可装配的文件。 - 如何在运行时将它加载到

运行时,就像它在构建时是项目中的引用一样?我知道

关于将程序集加载到当前appDomain中的事情但是不能
似乎能够找到如何做到这一点的示例。我对此的尝试已经失败了


I can load an assembly using the Assembly.Load(....)

However, I''d like dynamic loading of assemblies to be identical to putting
an assembly reference in your VS2005 project. and yes, I know about the
unloading problems. Let''s say I don''t care for the moment.

If I have an assemlbly file at "c:\\assembly.dll" - how do I load it at
runtime as if it were references in the project at build time? I know
something about loading an assembly into the current appDomain but can''t
seem to be able to find examples on how to do that. My attemps on this have
failed.



你的问题是什么并不是很清楚。你想要什么?b $ b当你加载一个没有发生的程序集时会发生什么?


当然你不能期望能够编译使用

的符号在编译时没有引用?


-

www.midnightbeach.com/.net

您需要了解的内容。

It''s not really clear what your question is. What do you want to
happen when you Load an Assembly that''s not happening?

Surely you don''t expect to be able to compile using symbols that
aren''t referenced at compile time?

--

www.midnightbeach.com/.net
What you need to know.


" Ron M. Newman" < co ********** @ confideltial.comschrieb:
"Ron M. Newman" <co**********@confideltial.comschrieb:

我可以使用Assembly.Load(....)加载程序集


但是,我希望动态加载程序集与在VS2005项目中放置

程序集引用相同。是的,我知道

卸货问题。让我们说我现在不在乎。


如果我在c:\\assembly.dll中有一个可装配的文件。 - 如何在运行时将它加载到

运行时,就像它在构建时是项目中的引用一样?
I can load an assembly using the Assembly.Load(....)

However, I''d like dynamic loading of assemblies to be identical to putting
an assembly reference in your VS2005 project. and yes, I know about the
unloading problems. Let''s say I don''t care for the moment.

If I have an assemlbly file at "c:\\assembly.dll" - how do I load it at
runtime as if it were references in the project at build time?



查看''Assembly.Load *''。


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/>

VB< URL:http://dotnet.mvps。 org / dotnet / faqs />

Check out ''Assembly.Load*''.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>





我正在使用属性网格我使用自定义类型编辑器和类型

转换器。这些属性是动态的,不是基于预先编译的

实施。为了使它能够与自定义编辑器一起使用并键入

变换器,您需要将这些类的完全限定名称输入到

结构中,然后输入到一个集合中。用于模拟动态属性的

ICustomTypeDescriptor。


这真的是一个属性网格问题,我把它作为背景

解释。这可能与我的问题无关。


我遇到的症状是


1)当自定义编辑器和typeConverter的类是预先的时候-compiled

与属性网格所在的主应用程序 - 一切

完美无缺。

2)当相同的类在一个动态加载的程序集'

程序集对象是主应用程序主要形式的成员 -

属性网格忽略输入并恢复为自己的标准

编辑/ typecoverter

3)情况#2 +在VS2005

项目中添加对装配的引用 - 它完美地工作。


这引发了我的问题。 #1和#3之间有什么区别?什么'

导致仅仅是Assembly.LoadFrom(...)无法正常运行 - 尽管我可以从它生成类型并且它们似乎有效。当我从该程序集中提交一串

a完全限定的类名时 - 它不能用它来加载

正确的类。

我的错误在哪里?


谢谢

Ron



" Herfried K. Wagner [MVP]" < hi *************** @ gmx.atwrote in message

news:OD ************** @ TK2MSFTNGP06.phx.gbl ...
Hi,

I am using a property grid and I use custom type editors and type
converters. The properties are dynamic, not based on pre-compiled
properties/attributes so I''m using the "propertyBag" exmample
implementation. In order for it to work with custom editors and type
coverters you need to enter the fully qualified name of those classes into a
structure and then into a collection which is then used by an
ICustomTypeDescriptor to simulate dynamic properties.

That''s really a property grid issue and i bring it as a background
explanation. It may be irrelevant to my question.

The symptoms I experience are

1) When the classes for the custom editor and typeConverter are pre-compiled
with the main application in which the property grid resides -- everything
works perfectly.
2) When the same classes are within a dynamically loaded assembly who''s
Assembly object is a member of the main form of the main application - the
property grid ignores the input and reverts to its own standard
editor/typecoverter
3) Situation #2 + adding a reference to the assembly in the VS2005
project -- it WORKS prefectly.

This triggered my question. What''s the difference between #1 and #3? what''s
causing a mere Assembly.LoadFrom(...) not to function properly - although I
can generate types from it and they seem to work. when I submit a string of
a fully qualified class name from that assembly - it can''t use it to load
the proper classes.

Where is my mistake?

Thanks
Ron


"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:OD**************@TK2MSFTNGP06.phx.gbl...

" Ron M. Newman" < co ********** @ confideltial.comschrieb:
"Ron M. Newman" <co**********@confideltial.comschrieb:

>我可以使用Assembly.Load加载程序集(... 。)

但是,我希望动态加载程序集与在VS2005项目中放置程序集引用相同。是的,我知道关于卸货问题。让我们说我现在不在乎。

如果我在c:\\assembly.dll中有一个可装配的文件。 - 如何在运行时加载它,就像在构建时它是项目中的引用一样?
>I can load an assembly using the Assembly.Load(....)

However, I''d like dynamic loading of assemblies to be identical to
putting an assembly reference in your VS2005 project. and yes, I know
about the unloading problems. Let''s say I don''t care for the moment.

If I have an assemlbly file at "c:\\assembly.dll" - how do I load it at
runtime as if it were references in the project at build time?



查看''Assembly.Load *''。


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/>

VB< URL:http://dotnet.mvps。组织/ DOTNET /常见问题/>


Check out ''Assembly.Load*''.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>



这篇关于大会圣人的一个有趣问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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