从 IronPython 调用 .NET 代码,加载 log4net 程序集时出错

发布于 2024-07-11 10:50:05 字数 540 浏览 4 评论 0原文

我有一个 IronPython 脚本,用于配置 log4net,然后调用使用 log4net 的 .NET 代码。 log4net 已正确配置,因为我记录了一条消息来表明它已初始化。 但是,当我尝试使用我的 .NET 类时,它报告“无法加载文件或程序集‘log4net,...’。

一些有用的事实:

  • log4net 未安装到 GAC
  • .NET 类是正确的,我已调用从其他 .NET 代码中,
  • 中加载的 log4net 程序集与我的 .NET 程序集位于同一文件夹中
  • filemon 显示所有 log4net.dll 访问均已从预期位置成功解析
  • fuslogvw 不会报告任何绑定错误
  • IPY 使用 AddReferenceToFileAndPath( ) 添加 log4net 引用和 .NET 程序集引用

奇怪的是 log4net 程序集已经被加载 它必须在另一个 AppDomain 中加载 .NET 程序集 如果这就是它的工作原理,那么这将很有帮助。有

什么想法吗?

I've got an IronPython script that configures log4net, then calls .NET code that uses log4net. log4net is properly configured, as I log a message to indicate that it is initialized. But when I try to use my .NET class, it reports "could not load file or assembly 'log4net, ...'.

Some useful facts:

  • log4net is not installed to the GAC
  • the .NET class is correct, I've called it from other .NET code
  • the log4net assembly being loaded in IPY is in the same folder as my .NET assembly.
  • filemon shows that all log4net.dll access is successfully resolved from the expected location
  • fuslogvw doesn't report any binding errors
  • I'm adding both the log4net reference and the .NET assembly references using AddReferenceToFileAndPath( )

What's strange is that the log4net assembly has already been loaded. It must be loading the .NET assembly in another AppDomain. If that's how it works, it would be helpful to know.

Any ideas out there? Thanks.

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

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

发布评论

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

评论(1

筱果果 2024-07-18 10:50:05

我能够通过使用绝对参考路径而不是相对路径来解决问题。

I was able to solve the problem by using absolute reference paths rather than relative ones.

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