加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

控制台不可用在类库c#

发布时间:2020-12-15 06:17:40 所属栏目:百科 来源:网络整理
导读:这个问题 here似乎与我所经历的相反.我无法从新的类库中访问控制台.我使用系统;在顶部.我在Windows 8上使用visual studio 11.我怀疑这在更新中已经丢失了,所以这意味着我做错了事情. 此外,一旦这个工作,便携式类库中的控制台是否可用? 编辑 这里只是我做的
这个问题 here似乎与我所经历的相反.我无法从新的类库中访问控制台.我使用系统;在顶部.我在Windows 8上使用visual studio 11.我怀疑这在更新中已经丢失了,所以这意味着我做错了事情.

此外,一旦这个工作,便携式类库中的控制台是否可用?

编辑

这里只是我做的测试文件

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AdamLib.util.ConsoleSupport
{
    class SafeRead
    {
        private void test()
        {
            System.Console.Writeline("test"); //Console is not found in system
        }
    }
}

这是在类库中.

解决

就像我以为,这是我的错.

感谢@DarinDimitrov,他指出,对于VS 11和地铁,控制台支持已被删除,可用于地铁.所以要解决这个问题,我需要用第二类类库创建一个新项目.有两个列出,我使用包含地铁的描述.要解决这个问题,我不得不在说明中使用没有地铁的其他类型.

再次感谢所有的帮助.

解决方法

如果您创建了Metro风格的应用程序,那么WinRT中没有控制台.不要搜索它,因为你不会找到任何.这在 this article中解释:

The subset of managed types and members was designed with a clear
focus on Metro style app development. As a result,it omits the
following:

  • Types and members that are not applicable to developing Metro style apps (such as console and ASP.NET types).

  • Obsolete and legacy types.

  • Types that overlap with Windows Runtime types.

  • Types and members that wrap operating system functionality (such as
    System.Diagnostics.EventLog and performance counters).

  • Members that cause confusion (such as the Close method on I/O types).

您可以使用debugging API或日志框架.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读