I have a some C code which does some security checks. From a C# .NET application I can access this through a DLL by using a DLLimport. However this is insecure because anyone could replace the DLL with one which always returns true to all my security checks.

Is there anyway I could statically link to the C library form .NET.

Or is there a good way to ensure the C DLL (not a .NET assembly) has not been tampered with?