程序集之间的.net事件 [英] .net events between assemblies

查看:84
本文介绍了程序集之间的.net事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

问题:是否可以注册一个.net程序集以轻松地从另一个程序集获取事件?

目前在两个程序集之间进行通信时,我使用的是远程处理,它工作正常,但我只是想知道我是否正在过多地使用它.

只是想知道.Net是否在后台有某种东西可以以更加无缝的方式进行处理...?

任何人?干杯

Julian

Hi all

Question: Is it possible to register one .net assembly to pick up events from another assembly easily?

At the moment for communication between two assemblies I am using remoting, which works fine, but am just wondering if I''m making too much of a meal of it.

Just wondering if .Net has something in the background to handle it in a more seamless fashion...?

Anyone? Cheers

Julian

推荐答案

首先要了解的是:程序集之间没有障碍(除非您人为地创建了更改程序集权限的障碍).无论您在一个装配中可以做什么,都可以在参考装配中进行.您只需使用publicprotected(在相同的类层次结构内)访问修饰符,而使用单个程序集,则只需internalinternal protected访问.

(如果真的需要动态加载程序集而不是引用它们(我指的是Abhinav的答案,因为您的要求根本不清楚,则需要开发一些插件技术.为此,我给出了全面的指导在我过去的答案中:
创建使用可重载插件的WPF应用程序... [ ^ ].
AppDomain拒绝加载程序集 [
First things to know: there is no barriers between assemblies (unless you artificially create barriers changing assembly permissions). Whatever you can do in one assembly, you can do in reference assembly. You only need to use public or protected (within the same class hierarchy) access modifiers while withing a single assembly you need only internal or internal protected access.

(If you really need to load assemblies dynamically instead of referencing them (I refer to the answer by Abhinav, as your request is not clear at all, you need to develop some plug-in technique. For this purpose, I have comprehensive directions given in my past answers:
Create WPF Application that uses Reloadable Plugins...[^].
AppDomain refuses to load an assembly[^].
Don''t think it''s too complex. Most likely, you don''t need the hard part of it related to the unloadable stuff and hence Application Domains.)

—SA


您可以考虑使用反射.


这篇关于程序集之间的.net事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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