Training
Module
Call methods from the .NET Class Library using C# - Training
Use functionality in the .NET Class Library by calling methods that return values, accept input parameters, and more.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
For .NET Programming, Visual C++ in Visual Studio 2017 supports the creation of mixed assemblies by using the /clr (Common Language Runtime Compilation) compiler option. The /clr:pure and clr:safe options are deprecated in Visual Studio 2015 and unsupported in Visual Studio 2017. If your code needs to be safe or verifiable, then we recommend that you port it to C#.
Mixed assemblies (compiled with /clr), contain both unmanaged and managed parts, making it possible for them to use .NET features, but still contain native code. This allows applications and components to be updated to use .NET features without requiring that the entire project be rewritten. Using Visual C++ to mix managed and native code in this fashion is called C++ Interop. For more information, see Mixed (Native and Managed) Assemblies and Native and .NET Interoperability.
Calls made from managed assemblies to native DLLs via P/Invoke will compile, but may fail at runtime depending on security settings.
There is one coding scenario that will pass the compiler but that will result in an unverifiable assembly: calling a virtual function through an object instance using the scope resolution operator. For example: MyObj -> A::VirtualFunction();
.
Training
Module
Call methods from the .NET Class Library using C# - Training
Use functionality in the .NET Class Library by calling methods that return values, accept input parameters, and more.
Documentation
Interoperability with Other .NET Languages (C++/CLI)
Learn more about: Interoperability with Other .NET Languages (C++/CLI)
Learn more about: C++/CLI Tasks
Native and .NET Interoperability
Learn more about: Native and .NET Interoperability