类型“System.IDisposable的”在未被引用的程序集中定义

编程入门 行业动态 更新时间:2024-10-28 18:29:30
本文介绍了类型“System.IDisposable的”在未被引用的程序集中定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创造了在Visual Studio 2012年Windows窗体应用程序在Windows 8上,而目标.NET框架4.5,我想使用Windows SDK的DatagramSocket的库,所以我改变了目标OS版本8,当我编译。

我收到以下错误:

  

类型System.IDisposable的在未被引用的程序集中定义错误1。你必须添加一个引用程序集System.Runtime,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a。

解决方案

如果您正在针对Windows 8的的 MSDN文档有如下说明:

  

这是说,你的桌面应用程序不能消耗太多的东西   Windows运行时,直到$ P $一个重要的ppare项目   参考。 Windows运行时定义了一些标准类和   在 System.Runtime 的接口,如的IEnumerable ,所使用的   整个Windows运行时库。默认情况下,您的管理   桌面应用程序将无法找到这些类型的,所以你必须   手动引用System.Runtime之前,你可以做任何事情   有意义的Windows运行时类。要创建本手册   参考:

        
  • 导航到在解决方案资源管理器管理的桌面应用程序的项目。
  •   
  • 右键单击引用节点,然后单击添加引用。
  •   
  • 点击浏览标签。
  •   
  • 点击浏览...
  •   
  • 导航到System.Runtime.dll外观。您通常可以找到这个在类似的路径:的%ProgramFiles(x86)的%\参考大会\微软\框架\ .NETFramework \ V4.5 \外立面\ System.Runtime.dll
  •   

    希望有所帮助。

    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 as IEnumerable, 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.

    更多推荐

    类型“System.IDisposable的”在未被引用的程序集中定义

    本文发布于:2023-11-06 04:57:17,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1562768.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:未被   定义   类型   程序   IDisposable

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!