IronRuby - 如何要求没有强名称的 .NET 程序集?

发布于 2024-08-20 07:18:40 字数 634 浏览 7 评论 0原文

IronRuby 帮助网站上的此页面讨论了能够“要求”一些好的内容- 已知程序集,例如 System.Windows.Forms,无需生成整个“ah-come-on-gimme-a-break-here-you-cannot-be-serious”强名称大会。

在文档中它这样说:

>>> require "System.Windows.Forms"  
=> true  

但是当我尝试相同的“要求”时,我得到这个:

>>> require "System.Windows.Forms"
IronRuby.Libraries:0:in 'require': no such file to load -- System.Windows.Forms (LoadError) 
        from :0:in 'Initialize##1'

我可能做错了什么?会不会是设置问题?我看不到文档中提到的“加载路径上的 libs 目录”。文档有误吗?

谢谢。

This page on the IronRuby help website talks about being able to 'require' some well-known assemblies such as System.Windows.Forms without needing to crank out the entire 'ah-come-on-gimme-a-break-here-you-cannot-be-serious' strong name of the assembly.

In the docs it says this:

>>> require "System.Windows.Forms"  
=> true  

But when I try the same 'require', I get this:

>>> require "System.Windows.Forms"
IronRuby.Libraries:0:in 'require': no such file to load -- System.Windows.Forms (LoadError) 
        from :0:in 'Initialize##1'

What might I be doing wrong? Could it be a setup problem? I can't see this "libs directory on the load path" that gets mentioned in the documentation. Is the documentation wrong?

Thanks.

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

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

发布评论

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

评论(2

飘落散花 2024-08-27 07:18:40

这是因为 IronRuby 的人编写了一堆包装脚本。

查看<您的ironruby安装路径>\lib\ironruby,您将看到System.Windows.Forms.rbSystem.Drawing.rb code> 等。

当您 require 'System.Windows.Forms' 时,IronRuby 会找到该 rb 文件并运行它。该文件中的代码只是为您完成完整的强命名要求。

如果您想加载其他尚未编写包装的 dll,您有 3 个选项:

  1. 需要 dll 的完整路径(例如 c:\program files\whatever\whatever\blah.dll< /code>)

  2. 需要强名称(这仅在以下情况下有效)它在 GAC 或其他 IronRuby 可以找到 dll 的地方)

  3. 使用 load_assemble - 这是最方便的,但 IIRC 它将 dll 加载到 LoadFrom 上下文中,而不是 Load 上下文中。
    如果您不明白这意味着什么,那么基本上在测试中没问题,但不要在生产中这样做:-)

The way that this works is because the IronRuby guys have written a bunch of wrapper scripts.

Look in <your ironruby install path>\lib\ironruby and you'll see System.Windows.Forms.rb, System.Drawing.rb etc.

What happens when you do require 'System.Windows.Forms' is that IronRuby finds that rb file and runs it. The code inside that file just does the full strong-named require for you.

If you want to load other dll's that they haven't written wrappers for, you have 3 options:

  1. require the full path to the dll (eg c:\program files\whatever\whatever\blah.dll)

  2. require the strong name (this only works if it's in the GAC or somewhere else IronRuby can find dll's in)

  3. use load_assembly - This is the most convenient, but IIRC it loads the dll into the LoadFrom context, not the Load context.
    If you don't understand what that means, then basically it's fine in testing, but don't do it in production :-)

凶凌 2024-08-27 07:18:40

嗯,这是一个设置问题 - IronRuby 下载中有两个 ir.exe 副本,而我使用了错误的副本。

Well, it was a setup problem - there were two copies of ir.exe in the IronRuby download, and I was using the wrong one.

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