.NET 有链接器吗?
下面的评论是什么意思?
// The line below only works when linked rather than
// referenced, as otherwise you need a cast.
// The compiler treats it as if it both takes and
// returns a dynamic value.
string value = com.MakeMeDynamic(10);
我明白什么是引用程序集。您可以在编译程序文件时使用命令行中的 /ref: 开关来引用它,也可以在 Visual Studio 中添加对程序集的静态引用。
但是如何链接到 .NET 中的程序集呢?他的意思是,使用反射(Assembly.LoadFile())加载程序集?或者,Win32 API LoadLibrary()?或者,.NET 是否有一个我从未听说过的链接器?
What does the following comment mean?
// The line below only works when linked rather than
// referenced, as otherwise you need a cast.
// The compiler treats it as if it both takes and
// returns a dynamic value.
string value = com.MakeMeDynamic(10);
I understand what referencing an assembly is. You may reference it when compiling the program files either using the /ref: switch at the command line or you may add a static reference to the assembly in Visual Studio.
But how do you link to an assembly in .NET? Does he mean, load the assembly using Reflection (Assembly.LoadFile())? Or, the Win32 API LoadLibrary()? Or, does .NET have a linker that I have never heard of?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,它用于 COM 主互操作程序集。在 .NET 4 中,您可以像平常一样引用它们,也可以“链接”/“嵌入”它们 - 在这种情况下,您最终只会将 PIA 中您感兴趣的部分嵌入到您自己的程序集中。
在命令行中,这是 C# 4 编译器的
/link:
选项。It's for COM Primary Interop Assemblies, basically. In .NET 4, you can either reference them as normal or "link" / "embed" them - in which case you end up with just the bits of the PIA that you're interested in embedded into your own assembly.
From the command line, this is the
/link:
option of the C# 4 compiler.