Question : Security Exception in P/Invoke from C# to Win32 DLL

Background:

I created a DLL using C++ and am calling the functions using Managed C# code with P/Invoke. I am receiving the below error after calling a Win32 API Function from within the DLL:

Unhandled Exception: System.AccessViolationException: Attempted to read or write
 protected memory. This is often an indication that other memory is corrupt.
   at GetFileSecurityW(Char* , UInt32 , Void* , UInt32 , UInt32* )
   at Query(_bstr_t* bstrPath)
   at Test.Program.Query(String strPath)
   at Test.Program.Main(String[] args) in Program.cs:line 23

Is this an issue with .NET security levels?

Answer : Security Exception in P/Invoke from C# to Win32 DLL

Random Solutions  
 
programming4us programming4us