I created a Windows Form application in Visual Studio 2012 on Windows 8, and the target .NET framework is 4.5, and I want to use the Datagramsocket library of Windows SDK, so I changed the target OS version to 8, when I compile.
I am getting the following error:
"Error 1 The type 'System.IDisposable' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'."
If you are targeting Windows 8, the MSDN documentation has the following instructions:
That said, your desktop app can’t consume much of anything from the Windows Runtime until you prepare your project with one essential reference. The Windows Runtime defines some standard classes and interfaces in
System.Runtime
, such asIEnumerable
, that are used throughout the Windows Runtime libraries. By default, your managed desktop app won’t be able to find these types, and so you must manually reference System.Runtime before you can do anything meaningful with Windows Runtime classes. To create this manual reference:
- Navigate to your managed desktop app project in the Solution Explorer.
- Right-click the References node and click Add Reference.
- Click the Browse tab.
- Click Browse….
- Navigate to the System.Runtime.dll façade. You can generally find this in a path similar to:
%ProgramFiles(x86)%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades\System.Runtime.dll
Hope that helps.
If you run into this problem with 4.5.2 and Unity, Microsoft has issued a fix, KB article: http://support.microsoft.com/kb/2971005
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With