Http://www.cnblogs.com/zengxlf/archive/2009/05/17/1458996.html
Let's just talk nonsense. Go to the topic.
Use vs2005 to create a Windows project named Test
Reference DLL files
WriteCode, Normally reference the class library in the DLL,
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.dll
Internal Static Byte [] Irisskin2 {
Get {
ObjectOBJ=ResourceManager. GetObject ("Irisskin2", Resourceculture );
Return((Byte[]) (OBJ ));
}
}
Then add the code to the main (program. CS) function.
Static Void Main ()
{
Application. enablevisualstyles ();
Application. setcompatibletextrenderingdefault ( False );
String Path = Application. startuppath + " \ " ;
String Dllfilename = " Irisskin2.dll " ;
// * ***** Load irisskin2.dll ******
If ( ! File. exists (Path + Dllfilename )) // File does not exist
{< br> 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 and generate the EXE file,
Then delete the referenced DLL file (note that the 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)