CodeDom Reference VB6 dll
I have had no problems adding .dll files (generated from Visual Studio) to a CodeDom generated executable file. To do so, I have been using the following code:
Code:
string[] referenceAssemblies = {
"System.dll",
"System.Windows.Forms.dll",
"System.Drawing.dll",
"System.Data.dll",
"System.Xml.dll"
};
// Add the referenced assemblies to the compiler parameteres
CompilerParameters cp = new CompilerParameters(referenceAssemblies, exeFile, false);
However, I would now like to add a Visual Basic 6 made .dll file as a reference to a CodeDom generated executable file. I do NOT, however want to add this .dll file as an embedded file. I want the .dll file to be the equivalent to doing the following in Visual Studio:
From Visual Studio:
- Open Visual Studio > New windows forms application
- References > Add Reference > Com Reference
- Call a function named 'Test(foo as string)' using the following
code:
Project1.Class1 vb6Test = new Project1.Class1();
vb6Test.Test("Some String");
From Visual Basic 6:
- New Project > Properties > Active X Dll
- Create new Class Module with Public modifiers and add in the following function:
- Create Project1.dll
Code:
public Function Test(foo as String)
MsgBox(foo)
End Function
Now, from Visual Studio I am able to add Project1.dll as a reference to my winform application and call it using the code above (in the Visual Studio section). I want to incorporate the exact same functionalitiy through the use of CodeDom. However, I am encountering a CodeDom error during code generation:
CodeDom code - Including the .dll file as a referenced assembly:
string[] referenceAssemblies = {
"System.dll",
"System.Windows.Forms.dll",
"System.Drawing.dll",
"System.Data.dll",
"System.Xml.dll",
@"C:\Users\EVAN\Desktop\file.dll"
};
Error:
Metadata file 'c:\Users\EVAN\Desktop\file.d开发者_开发技巧ll' could not be opened -- 'An attempt was made to load a program with an incorrect format. '
I have no idea what the problem could be as Visual Studio has no problem loading it as a reference, when I do it manually.
I can't wait to hear what you all have to say!
Thank you,
Evan
精彩评论