控制台类库C#中不可用 [英] Console unavailable in class library c#

查看:146
本文介绍了控制台类库C#中不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题这里似乎违背了什么,我都经历过。我无法从一个新的类库中访问控制台。我有使用系统; 上方。我使用的Visual Studio 11在Windows 8.我怀疑这已在更新丢失了,这样就意味着我做错了什么。

This question here seems contrary to what I have experienced. I cannot access the console from within a new class library. I have using System; at the top. I am using visual studio 11 on windows 8. I doubt that this has been lost in the update, so that means that I am doing something wrong.

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

Also, once this is working, is the console available in a portable class library?

修改

这里只是我做了

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
        }
    }
}



发现

这是在类库。

This is in the class library.

议决

像我想,这是我的错。

感谢@DarinDimitrov,谁指出,与VS 11和地铁,控制台支持已经与地铁使用的去除。因此,要解决这个我需要创建与第二种类库的新项目。有两家上市,我用一个,包括地铁的描述。要解决这个问题,我不得不使用其他类型的无说明地铁。

Thanks to @DarinDimitrov, who pointed out that with VS 11 and metro, Console support has been removed for use with metro. So to resolve this I needed to create a new project with the second kind of class library. There are two listed and I used the one with the description that includes metro. To resolve the issue, I had to use the other type without metro in the description.

再次感谢所有帮助。

推荐答案

如果您创建了一个Metro风格的应用程序,有一个在WinRT中没有控制台。不要寻找它,你不会找到任何。这在这篇文章:

If you created a Metro style application, there's no Console in WinRT. Don't search for it as you won't find any. This is explained in this article:

管理类型和成员的子集的设计带有明显的
专注于Metro风格应用的发展。其结果是,它省略了
如下:

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:


  • 类型和成员,并不适用于开发Metro风格应用程序(如控制台和ASP.NET类型)。

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

过时和传统的类型。

这与Windows运行时类型重叠类型。

Types that overlap with Windows Runtime types.

类型和成员包的操作系统功能(如
System.Diagnostics.EventLog和性能计数器)。

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

成员引起混乱(如I / O类型Close方法)。

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

您可以使用的调试API 或日志框架。

You could use the debugging API or logging framework.

这篇关于控制台类库C#中不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆