Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

How to: Create a Partially Trusted Application by Removing Dependency on msvcm80.dll 

This topic discusses how to create a partially trusted Common Language Runtime application using Visual C++ by removing dependency on msvcm80.dll.

A Visual C++ application built with /clr will have a dependency on msvcm80.dll, which is part of the C-Runtime Library. When you want your application to be used in a partial trust environment, the CLR will enforce certain code access security rules on your DLL. Therefore, it will be necessary to remove this dependency because msvcm80.dll contains native code and code access security policy cannot be enforced on it.

If your application does not use any functionality of the C-Runtime Library and you would like to remove the dependency on this library from your code, you will have to use the /NODEFAULTLIB:msvcmrt.lib linker option and link with either ptrustm.lib or ptrustmd.lib. These libraries contain object files for initialization and uninitialization of an application, exception classes used by the initialization code, and managed exception handling code. Linking in one of these libraries will remove any dependency on msvcm80.dll.


The order of assembly uninitialization might differ for applications that use the ptrust libraries. For normal applications, assemblies are usually unloaded in the reverse order that they are loaded, but this is not guaranteed. For partial trust applications, assemblies are usually unloaded in the same order that they are loaded. This, also, is not guaranteed.

To create a partially trusted mixed (/clr) application

  1. To remove the dependency on msvcm80.dll, you must specify to the linker not to include this library by using the /NODEFAULTLIB:msvcmrt.lib linker option. For information on how to do this using the Visual Studio development environment or programmatically, see /NODEFAULTLIB (Ignore Libraries).

  2. Add one of the ptrustm libraries to the linker input dependencies. Use ptrustm.lib if you are building your application in release mode. For debug mode, use ptrustmd.lib. For information on how to do this using the Visual Studio development environment or programmatically, see .lib Files as Linker Input.

See Also

Community Additions

© 2015 Microsoft