C# calling C++ dll attempts to read or write protected memory -


I am trying to use function drom to use DLL, but I get the XamlParseException But I'm seeing my program running from the stage while I get a AccessViolationException , which I think is the reason for the first exception.
In fact, to use different sections to interact with the program what the function was supposed to do, log me into a program directory.
I do not have access to the source of DLL, but I have some documents to use it, even if nobody has a lot of information here, here's how to use it:

  logon (BSTR directory path, BSTR error file, int Lang)   

And here is my code:

  Public partial square main window: Window {[DllImport ("kernel32.dll")] static extern IntPtr LoadLibrary (string dllToLoad); [DllImport ("kernel32.dll", Charset = CharSet.Ansi, ExactSpelling = true, SetLastError = true)) Public static extern IntPtr GetProcAddress (IntPtr hModule, String Procedure Name); [Unmanaged Function Pointer (Calling Convention Winpipe)] Personal Reporter Ent Logon ([Marshall AS (Unhandled Type BST)] String Directory Path [Marshall AS (Unhandled Type BST)] String Error File, Int Land; Public Manvindo () {Initialization (); Try {string LnkPsbEppPath = "dll / LnkPsbEpp.dll"; IntPtr pAddressFctLogon = GetProcAddress (LnkPsbEppLink, "@Tdm_Dossier @ Logon $ qv"); If (pAddressFctLogon == IntPtr.Zero) console WrightLine ("Logon function not found"); Else {try {dynamic logon = Marshal.GetDelegateForFunctionPointer (pAddressFctLogon, typeof (logon)); Dynamic varLogon = logon (directory, error, file path, 2); // & lt; - Here is where AccessViolationException happend} Catch (Exception precedent) {}}} Catch (Exceptional Before) {Console.WriteLine ("Error:" + previous message); }}}}    

Check whether C ++ dll will allow you to write it Offers.

Check the C + + DLL document for more information

Even I faced the same problem when I Using C ++ DLL in its WPF application

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -