无法加载文件或程序集

发布于 2024-10-06 00:03:54 字数 413 浏览 0 评论 0原文

我无法在 Linqpad 中的另一个应用程序域中执行代码:


void Main()
{
AppDomain.CreateDomain("AD").DoCallBack(() => { Console.WriteLine("Test"); });
}

每次执行代码时都会收到不同的文件未找到异常

无法加载文件或程序集'query_gclnfu,版本=0.0.0.0、Culture=neutral、PublicKeyToken=null' 或其依赖项之一。

无法加载文件或程序集“query_blixbs,Version=0.0.0.0,Culture=neutral,PublicKeyToken=null”或其依赖项之一。

我一无所知...

I'm not able to execute code in another application domain in Linqpad:


void Main()
{
AppDomain.CreateDomain("AD").DoCallBack(() => { Console.WriteLine("Test"); });
}

I get a different file not found exception each time I execute the code:

Could not load file or assembly 'query_gclnfu, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

Could not load file or assembly 'query_blixbs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

I'm clueless...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沩ん囻菔务 2024-10-13 00:03:54

LINQPad 通过简单的沙箱 API 在应用程序域中运行您的代码,这意味着如果您使用 AppDomain.CreateDomain 创建域,您将遇到权限问题。

LINQPad 提供了一个帮助程序方法来创建具有正确权限和程序集解析处理程序设置的应用程序域:

Util.CreateAppDomain ("AD").DoCallBack(() => { Console.WriteLine("Test"); });

这将运行而不会出现错误,尽管您不会在输出窗口中看到“测试”,因为新的应用程序域不会有它的控制台输出被重定向。不过,以下内容将起作用:

Util.CreateAppDomain ("AD").DoCallBack(() => MessageBox.Show ("test"));

LINQPad runs your code in an app domain via the simple sandboxing API, and this means that you'll run into permission issues if you create a domain using AppDomain.CreateDomain.

LINQPad offers a helper method to create an app domain with the right permissions and assembly resolution handlers set up:

Util.CreateAppDomain ("AD").DoCallBack(() => { Console.WriteLine("Test"); });

This will run without error, although you won't see "Test" appear in the output window because the new app domain won't have its console output redirected. The following will work, though:

Util.CreateAppDomain ("AD").DoCallBack(() => MessageBox.Show ("test"));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文