且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在运行时使用windows api编译vb.net代码

更新时间:2023-01-15 20:42:41

kosay85写道:
kosay85 wrote:

我以windows API为例使用外部dll文件。一般来说我如何使用带有CodeDOM的dll文件?

I give windows API as an example to use external dll files . in general how I can use dll files with CodeDOM ??

这就是

https://msdn.microsoft.com/en-us/library/system.codedom.compiler.compilerparameters%28v=vs.110%29.aspx [ ^ ],

https://msdn.microsoft.com/en-us/library/system.codedom.compiler.compilerparameters.compilerparameters%28v=vs.110%29.aspx [ ^ ]。



对于带参数的构造函数,第一个是参考数组ed程序集名称。



要查看 CompilerParameters 的位置,请参阅此MDSN页面上的代码示例并阅读整个概述: https://msdn.microsoft.com/ en-us / library / saf5ce06%28v = vs.110%29.aspx [ ^ ]。



有两个重要的事情:1)你永远不会需要使用P / Invoke(来自kernel32.dll或其他任何东西); CodeDOM为您提供编译程序集的所有功能;仅使用P / Invoke会影响您的平台兼容性,因此仅在特殊需要时使用它; 2)使用.NET,您不应该考虑DLL,中心概念是可以使用一个或多个模块的程序集; DLL是其中一个模块; EXE,DLL或其他任何东西之间没有根本区别(EXE也有一个入口点,那又怎么样?);它只是不同的文件命名模式。



-SA

This is how
https://msdn.microsoft.com/en-us/library/system.codedom.compiler.compilerparameters%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/system.codedom.compiler.compilerparameters.compilerparameters%28v=vs.110%29.aspx[^].

For the constructors with arguments, first one is the array of referenced assembly names.

To see where CompilerParameters come into play, please see the code sample on this MDSN page and read the whole overview: https://msdn.microsoft.com/en-us/library/saf5ce06%28v=vs.110%29.aspx[^].

There are two important things: 1) you never need to use P/Invoke (from "kernel32.dll" or anything else); CodeDOM gives you everything to compile assemblies and a lot more; using P/Invoke only can compromise your platform compatibility, so use it only in special need; 2) with .NET, you should not think in terms of DLLs, the central concept is assembly which can use one or more modules; a DLL is one of the modules; there is no fundamental difference between EXE, DLL or anything else (EXE also has an entry point, so what?); it's just different file naming patterns.

—SA