Using C++ dlls in event receiver
-
10-12-2019 - |
Question
I am trying to use a legacy C++ dll that has around 5 C/C++ dependencies in SharePoint. I created a wrapper for the dll and it works fine in a test desktop program. I added the wrapper and all C++ libraries to the event receiver assembly and they are being deployed to the WebApplication target. When I run the receiver I get
SecurityException was unhandled by user code System.Security.Permission.SecurityPermission
when it hits the C++ method.
Next, I tried using SPSecurity.RunWithElevatedPrivileges()
in the wrapper but I get
SecurityException was unhandled by user code Microsoft.SharePoint.Security.SharePointPermission`.
How can I get the C++ library to work?
Solution
This isn't a SP security issue, it's a file system security issue. Make sure the identity running this code has permissions to read the file system.
Make sure your C++ library has sufficient file permissions so that SharePoint can access it. You can match permissions with your development environment.
Other then that all I can think of is trust levels of your web application, check this link out that is explaining how trust levels are setup in different environment as your development machine web app might have full trust level.