开发者

c# Problems with repeated console.writeline commands

I am coding a c# command line application (WIN7, 64bit) that should write many lines to the command line.

I cooked the problem down to the following code:

        int lineno;
        for (lineno = 0; lineno < 1开发者_开发技巧00000; lineno++) { 
            Console.WriteLine(">" + lineno);
        }

I can't understand why the apllication dies after 39404 lines:

...

>39401

>39402

>39403

>39404

"Console Application has stopped working."

Please let me know if you have any ideas what went wrong here.

Thank you & best regards, Dirk.


I doubt your question. Because my program works fine and shows till 99999 under MS Visual Studio 2008.

c# Problems with repeated console.writeline commands


EDIT : After Dirk commented on Davido's answer, with Console.WriteLine(">>>" + lineno); the output prints many 36251 times. But that's incorrect. With ">>>" also, program accurately works.

Here's image for same.

c# Problems with repeated console.writeline commands


I couldn't reproduce the problem--it seems the problem is environment.

Does it always fail at 39404? Does it fail after a certain period of time? How do you launch it? Have you tried launching it from command line? Are you sure this is all code that you have? Have you tried building it with different configurations?

Answering these questions, you might find what causes the problem.

Edit: the oddest thing I see about it is this message:

"Console Application has stopped working."

It's obviously not system or framework message.
Please post complete code because it looks like you're doing something wrong.


Works fine on my system. (Windows 7, VS 2010).

c# Problems with repeated console.writeline commands

What Operating System and Framework version are you using?


Try changing your application target to compile for x86. Sometimes this solves strange issues I have with different projects.

Edit:

Dirk, try making a NEW project and putting your code in a blank console project. See if that changes how it outputs. I suspect that doing this will change the number of lines you are able to write. If so, then there is a problem with some of your other code that you haven't posted. Just something you might want to consider.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜