title: Compiler warnings C4691 when referencing NuGet package in C++/CLR project
body: <p>I have the following situation within Visual Studio 2017:</p>
  
  <p>A C++ project which is compiled with the /clr (Common Language Runtime Support switch) has a depedency to Microsoft.Practices.Unity, since we use the IUnityContainer therein. However, several warnings arise in the cpp-File where the reference is made:</p>
  
  <pre><code>using namespace Microsoft::Practices::Unity;
  </code></pre>
  
  <p>The warnings after build:</p>
  
  <pre><code>warning C4691: 'System::Object': type referenced was expected in unreferenced assembly 'System.Runtime', type defined in current translation unit used instead
  note: This diagnostic occurred while importing type 'Microsoft::Practices::Unity::UnityContainer ' from assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f'.
  warning C4691: 'System::IDisposable': type referenced was expected in unreferenced assembly 'System.Runtime', type defined in current translation unit used instead
  note: This diagnostic occurred while importing type 'Microsoft::Practices::Unity::IUnityContainer ' from assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f'.
  note: This diagnostic occurred while importing type 'Microsoft::Practices::Unity::UnityContainer ' from assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f'.
  warning C4691: 'System::Collections::Generic::IEnumerable': type referenced was expected in unreferenced assembly 'System.Runtime', type defined in current translation unit used instead
  note: This diagnostic occurred while importing type 'Microsoft::Practices::Unity::IUnityContainer ' from assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f'.
  note: This diagnostic occurred while importing type 'Microsoft::Practices::Unity::UnityContainer ' from assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f'.
  warning C4691: 'System::ParamArrayAttribute': type referenced was expected in unreferenced assembly 'System.Runtime', type defined in current translation unit used instead
  note: This diagnostic occurred while importing type 'Microsoft::Practices::Unity::IUnityContainer ' from assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f'.
  note: This diagnostic occurred while importing type 'Microsoft::Practices::Unity::UnityContainer ' from assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f'.
  warning C4691: 'System::Type': type referenced was expected in unreferenced assembly 'System.Runtime', type defined in current translation unit used instead
  note: This diagnostic occurred while importing type 'Microsoft::Practices::Unity::IUnityContainer ' from assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f'.
  note: This diagnostic occurred while importing type 'Microsoft::Practices::Unity::UnityContainer ' from assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f'.
  warning C4691: 'System::EventHandler': type referenced was expected in unreferenced assembly 'System.Runtime', type defined in current translation unit used instead
  note: This diagnostic occurred while importing type 'Microsoft::Practices::Unity::UnityContainer ' from assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f'.
  warning C4691: 'System::Collections::Generic::IDictionary': type referenced was expected in unreferenced assembly 'System.Runtime', type defined in current translation unit used instead
  note: This diagnostic occurred while importing type 'Microsoft::Practices::Unity::UnityContainer ' from assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f'.
  warning C4691: 'System::Collections::Generic::List': type referenced was expected in unreferenced assembly 'System.Collections', type defined in current translation unit used instead
  note: This diagnostic occurred while importing type 'Microsoft::Practices::Unity::UnityContainer ' from assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f'.
  warning C4691: 'System::Action': type referenced was expected in unreferenced assembly 'System.Runtime', type defined in current translation unit used instead
  note: This diagnostic occurred while importing type 'Microsoft::Practices::Unity::UnityContainer ' from assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f'.
  </code></pre>
  
  <p>I already found the following topics on several places, which seem to somehow address this issue, but unfortunately without any fix that helped in my case.</p>
  
  <ul>
  <li><a href="https://github.com/aspnet/Logging/issues/734" rel="nofollow noreferrer">https://github.com/aspnet/Logging/issues/734</a></li>
  <li><a href="https://github.com/dotnet/sdk/issues/1781" rel="nofollow noreferrer">https://github.com/dotnet/sdk/issues/1781</a></li>
  <li><a href="https://developercommunity.visualstudio.com/content/problem/158463/c4691-warnings-with-ccli-nuget.html" rel="nofollow noreferrer">https://developercommunity.visualstudio.com/content/problem/158463/c4691-warnings-with-ccli-nuget.html</a></li>
  </ul>
  
  <p>Has anyone already found a solution to avoid this warning, apart from deactivating it by #pragma?</p>
  
  <hr>
  
  <p><strong><em>Amendment</em></strong>:
  The problem is simply reproducible by creating a new CLR Console Application project within Visual Studio 2017, add a reference to the Microsoft.Practices.Unity.dll (Version 4.0.1, from the net45 folder of the NuGet packages) and the following snippet:</p>
  
  <pre><code>#include "stdafx.h"
  
  using namespace System;
  
  
  int main(array&lt;System::String ^&gt; ^args)
  {
    Microsoft::Practices::Unity::IUnityContainer^ unityContainer = gcnew Microsoft::Practices::Unity::UnityContainer();
    return 0;
  }
  </code></pre>