PDA

View Full Version : سوال: خطا موفع اضافه کردن فایل DLL



smym271
یک شنبه 24 اردیبهشت 1391, 17:43 عصر
سلام

زمانی که فایل sapi.dll رو در ویژوال استودیو 2008 از مسیر زیر اضافه میکنم طبق تصویر با خطا مواجه میشم ، مشکل از کجاست ؟ ممکنه از نسخه نرم افزار باشه ؟

Project > add refrence

87024

tooraj_azizi_1035
یک شنبه 24 اردیبهشت 1391, 22:13 عصر
سلام
مراحلی رو که گفته دنبال کن:



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.Propert ies.Resources.DLLName + ".DLL") == false)
{


System.IO.StreamWriter OutStream;
System.IO.BinaryWriter BinStream;
// Create the DLL file

OutStream = new System.IO.StreamWriter(USBXpress_TestPanel.Propert ies.Resources.DLLName + ".DLL", false);
BinStream = new System.IO.BinaryWriter(OutStream.BaseStream);
BinStream.Write(USBXpress_TestPanel.Properties.Res ources.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.