سلام
مراحلی رو که گفته دنبال کن:
Step 1) Add the DLL as a resource. To do this open the project, select the resources tab, select "add existing file" and add the DLL as a resource.
Step 2) Add the name of the DLL as a string resource.
Step 3) Add this code to your main form-load: (In this example my project is called "USBXpress_TestPanel", and the DLL file I'm using is "SiUSBXp.dll").
Code Snippet
if (System.IO.File.Exists(USBXpress_TestPanel.Properties.Resources.DLLName + ".DLL") == false)
{
StreamWriter OutStream;
System.IO.BinaryWriter BinStream;
// Create the DLL file
OutStream =
new System.IO.StreamWriter(USBXpress_TestPanel.Properties.Resources.DLLName + ".DLL", false);
BinStream = new System.IO.BinaryWriter(OutStream.BaseStream);
BinStream.Write(USBXpress_TestPanel.Properties.Resources.SiUSBXp);
BinStream.Close();
}
So the first time your code runs it will detect the missing DLL in it's default directory and create the file. This way the DLL is actually embedded in your exe, so you don't have to mess with the deployment files or anything.