是否有可能导致在另一个应用程序域中创建线程?
假设我有一个非默认应用程序域。我想获取对默认应用程序域的引用,并在其中创建一个线程,该线程运行一段代码。这可能吗?我能想到的唯一方法是将我的程序集重新加载到默认应用程序域中,并在类型的构造函数之一中包含一些逻辑,该类型的构造函数确定它已被重新加载以启动此新线程。这看起来相当复杂。有没有更直接的方法来做到这一点?另一方面,如果有一种方法可以做到这一点,那么似乎可以绕过 .NET 的整个安全模型。
Let's say I have a non default app domain. I want to get a reference to the Default app domain and cause a thread to be created within it, that runs a piece of code. Is this possible? The only way I can think of doing this is to re-load my assembly into the Default app domain and have some logic in one of the constructors of a type that figures out it's been reloaded for the purpose of launching this new thread. That seems rather convoluted. Is there a more direct way of doing this? On the other hand if there were a way of doing it, it would seem that would circumvent the entire security model of .NET.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试这个。在示例中,在第二个 AppDomain 中调用主机实例上的 GetAssemblyNames。该方法可以轻松启动一个线程来调用您的代码。
Try this. In the example, the call to GetAssemblyNames on the host instance is called in the second AppDomain. That method could easily start a thread to call your code.