Question

In C#, Is it possible to dynamicaly load a .NET library at runtime with using something like System.Reflection.Assembly.LoadFile & disabling the loaded library from using [DllImport("someCPP.DLL", EntryPoint ="someFunction")] so that you can't call c++ stuff for security reasons??


The reason for this question is i'm thinking about making a generic openSource browser plugin that could run any .NET code & display things like OpenGL or Direct3D or whatever content you want in the browser using .NET. This would need the loaded .NET library to be secure though by disabling "DllImport" & maybe some other things. Is this possible?

Was it helpful?

Solution

You can use an application domain with restricted security permissions.

Here is a general introduction to application domains:

And here is the specific permission related to executing unmanaged code:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top