Console.WriteLine()未在屏幕上显示任何输出 [英] Console.WriteLine() is not showing any output on screen

查看:363
本文介绍了Console.WriteLine()未在屏幕上显示任何输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅我的wcf服务,

这里每当我打电话

please refer to my wcf service,
Here Whenever i call

client.Display();



我没有输出。



界面:IMyClass




I am getting no output.

Interface: IMyClass

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace SecondWCFLibrary
{
    [ServiceContract]
    public interface IMyClass
    {
        [OperationContract]
        void Display(string s);
    }
}







班级(服务):MyClass






Class(Service): MyClass

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

namespace SecondWCFLibrary
{
    class MyClass:IMyClass
    {
        public void Display(string s)
        {
            Console.WriteLine("Hello..."+s);
        }
    }
}







我的客户端应用程序(控制台):






And my Client application(Console):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.IO;

namespace MyConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            string name;

            Console.WriteLine("Enter your name....");
            name = Console.ReadLine();
            MyConsole.MyService.MyClassClient client = new MyConsole.MyService.MyClassClient();


            client.Display(name);
            Console.WriteLine("Executed....");
            Console.ReadLine();

        }
    }
}

推荐答案

这是正常行为。最有可能的是,它可以正常工作,但你没有控制台。 :-)

这不是一个笑话:如果您尝试重定向控制台输出,您可以看到输出实际执行但不可见。



要使控制台输出可见,您需要将应用程序类型更改为控制台应用程序。这是在项目属性,第一个选项卡(应用程序)中完成的。顺便说一句,如果您的应用程序是WPF或System.Windows.Forms,它将保留在Windows应用程序中,只会添加控制台。



- SA
This is a normal behavior. Most likely, it works correctly, but you don't have console. :-)
This is not quite a joke: if you experiment with redirection of console output, you can see that the output is actually performed but not visible.

To make a console output visible, you need to change application type to "Console application". This is done in the project "Properties", first tab ("Application"). By the way, if you application was WPF or System.Windows.Forms, it will remain the windows application, only the console will be added.

—SA


我自己解决了这个问题。

谢谢大家的帮助......:)
I have solved this myself.
Thank you all for helping me... :)


这篇关于Console.WriteLine()未在屏幕上显示任何输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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