在Visual Studio中,我可以点击“引用”>“添加引用”,并浏览计算机上现有的.dll文件。然后我可以按照以下方式使用已引用的dll:
dllNameSpace.dllClassName myReference = new dllNameSpace.dllClassName();
myReference.someVoid();
我知道如何使用CodeDom添加引用程序集(将在下面展示),但是实际的dll文件没有像在Visual Studio中操作时那样被添加到项目中。再次强调,我需要能够调用我想要引用的dll文件中的某些函数。
我现在正在做什么:
// Configure a CompilerParameters that links the system.dll and produces the specified executable file.
string[] referenceAssemblies = {
"System.dll",
"System.Drawing.dll",
"System.Windows.Forms.dll",
"System.Data.dll",
"System.Xml.dll",
"System.Management.dll",
Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\myDllFile.dll"
};
CompilerParameters cp = new CompilerParameters(referenceAssemblies, exeFile, false);
我假设我需要采取一些不同的措施,以便CodeDom将dll添加到输出可执行文件中。还需要做什么?
感谢大家的帮助!
dll
文件中的函数!!! - Mousa Alfhaily