السلام عليكم ورحمة الله
اهلا شباب انا كنت بعمل كود علشان اشغل بيه وظايف قراءة وكتابة على memory card
فكنت باستخدم dll اللى مع البرنامج
import dllبتاع
البرنامج وتمام عملت وابتديت انادى على
functions
بخصوص الكود بتاعى
انا عملت import for dll
[DllImport("SCARD32.DLL", EntryPoint="SCardComand", SetLastError=true, CallingConvention=CallingConvention.Winapi, CharSet=CharSet.Ansi, ExactSpelling=true)]
public static extern int SCardComand(int handle , [MarshalAs(UnmanagedType.BStr)] string cmd , int cmdLen , [MarshalAs(UnmanagedType.BStr)] string dataIn, int dataInLen , [MarshalAs(UnmanagedType.BStr)] string dataOut, int dataOutLen);
وعملت ليها function
وكله تمام وعملت على سبيل التجربة
read memory function
int L;
string D = " ";
//D = String(200, 0);
string nil="";
L = SCardComand(0, "Card,Memread,1152,1183", 0, nil, 0, D, 200);
MessageBox.Show(D);
ولما جيت اعمل ليها run
طلع ليا Exception
************** Exception Text **************
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at WindowsApplication1.Form1.SCardComand(Int32 handle, String cmd, Int32 cmdLen, String dataIn, Int32 dataInLen, String dataOut, Int32 dataOutLen)
at WindowsApplication1.Form1.button1_Click(Object sender, EventArgs e) in I:\s\s\Form1.cs:line 41
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///D:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
s
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///I:/s/s/bin/Release/s.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///D:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///D:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///D:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
مع العلم انا باستخدم vc#2005
وعملتimport unmanaged
dll
انا حاولت مع الexception ده بس مش عارف اتعامل معاه كل مرة لما بيعمل dubgging
متشكر جدا يا اخوانى على تعبكم معانا
وجزاك الله خيرا
ماجد
