Let's just talk nonsense. Go to the topic.
Use VS2005 to create a windows project named test
Reference dll files
Compile the code and reference the class library in the dll normally,
Add a resource file to the test project (this file is the dll file just referenced)
VS2005 will automatically generate the reference code. Here I reference IrisSkin2.dllCopy codeThe Code is as follows: internal static byte [] IrisSkin2 {
Get {
Object obj = ResourceManager. GetObject ("IrisSkin2", resourceCulture );
Return (byte []) (obj ));
}
}
Then add the code to the Main (program. cs) function.Copy codeThe Code is as follows: static void Main ()
{
Application. EnableVisualStyles ();
Application. SetCompatibleTextRenderingDefault (false );
String path = Application. StartupPath + "\";
String dllFileName = "IrisSkin2.dll ";
// ****** Load IrisSkin2.dll ******
If (! File. Exists (path + dllFileName) // the File does not exist
{
FileStream fs = new FileStream (path + dllFileName, FileMode. CreateNew, FileAccess. Write );
Byte [] buffer = GetData. Properties. Resources. IrisSkin2; // {GetData is the namespace}
Fs. Write (buffer, 0, buffer. Length );
Fs. Close ();
}
//*****************************
Application. Run (new GDForm ());
}
Compile the test project, generate the exe file, and then delete the referenced dll file (note that the dll file is compiled first and then deleted)
Copy the exe file to run it elsewhere (no dll is needed, and running the EXE will automatically generate the DLL file)