大字符串常量会导致C#编译器崩溃 [英] Large string constant causes C# compiler crash

查看:99
本文介绍了大字符串常量会导致C#编译器崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个带有一些大字符串常量的C#应用​​程序,每当我尝试构建解决方案时,编译器崩溃时都没有错误消息。在

进一步分析时,当字符串常量大约为2100字符时,问题似乎发生了。我尝试将常量声明更改为字符串

变量声明,它工作正常。


有什么想法吗?


以下代码可用于重现错误:


const string TEST =

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +

" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" ;;


问候

Gnik

I created a C# application with some large string constants and whenever I
try to build the solution the compiler crashes with no error message. On
further analysis the problem seems to occur when the string constant has
around 2100 character. I tried changing the constant declaration to a string
variable declaration and it works fine.

Any ideas?

The following code can be used to reproduce the error:

const string TEST =
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" +
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0";

Regards
Gnik

推荐答案

就我而言,这不应该导致崩溃 - 实际上我的机器上没有b
。也许你应该发布你的问题的完整代码(也许是你的机器上有物理内存问题吗?)。

Gnik < GN ** @ discussions.microsoft.com>在留言中写道

新闻:A7 ********************************** @ microsof t.com ...
As far as I am concerned, that shouldn''t cause a crash -and indeed doesn''t
on my machine. Maybe you should post the full code of your problem (perhaps
you have a physical memory problem on your machine?).
"Gnik" <Gn**@discussions.microsoft.com> wrote in message
news:A7**********************************@microsof t.com...
我创建了一个带有一些大字符串常量的C#应用​​程序,每当我尝试构建解决方案时,编译器崩溃时都没有错误消息。在进一步分析时,当字符串常量大约为2100字符时,似乎会出现问题。我尝试将常量声明更改为
字符串
变量声明,它工作正常。

任何想法?

以下代码可用于重现该错误:

常量字符串TEST =
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0& QUOT;
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 012345 67890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" <无线电通信/> +
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+ <无线电通信/>" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" ;;

关于
Gn ik
I created a C# application with some large string constants and whenever I
try to build the solution the compiler crashes with no error message. On
further analysis the problem seems to occur when the string constant has
around 2100 character. I tried changing the constant declaration to a
string
variable declaration and it works fine.

Any ideas?

The following code can be used to reproduce the error:

const string TEST =
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0";

Regards
Gnik



Gnik写道:
我创建了一个带有一些大字符串常量的C#应用​​程序,每当我尝试构建解决方案编译器崩溃没有错误消息。在进一步分析时,当字符串常量大约为2100字符时,似乎会出现问题。我尝试将常量声明更改为字符串
变量声明,它工作正常。

任何想法?
I created a C# application with some large string constants and whenever I
try to build the solution the compiler crashes with no error message. On
further analysis the problem seems to occur when the string constant has
around 2100 character. I tried changing the constant declaration to a string
variable declaration and it works fine.

Any ideas?




无法在这里重现。编译并执行正常。

-

Tom Porterfield



Not able to reproduce here. Compiles and executes fine.
--
Tom Porterfield


完整代码只是粘贴的代码行进入

默认控制台应用程序的主要功能。这是一个简单的测试应用程序来诊断问题。


我在两台不同的机器上尝试了同样的事情,结果相同

运行Windows XP SP2,一个具有256 Mb RAM,另一个具有1 Gb RAM。我是Visual Studio .NET 2003(7.1.3088)和.NET Framework 1.1 SP1(1.1.4322)上的



" Mark Broadbent" ;写道:
The full code is simply that line of code pasted into the Main function of a
default console application. It was a simple test app to diagnose the issue.

I''ve tried the same thing on 2 different machines with the same results both
running Windows XP SP2, one with 256 Mb RAM and the other with 1 Gb RAM. I''m
on Visual Studio .NET 2003 (7.1.3088) and .NET Framework 1.1 SP1 (1.1.4322)

"Mark Broadbent" wrote:
就我而言,这不应该导致崩溃 - 实际上并没有在我的机器上。也许你应该发布问题的完整代码(或许你的机器上有物理内存问题?)。

Gnik < GN ** @ discussions.microsoft.com>在消息中写道
新闻:A7 ********************************** @ microsof t.com。 ..
As far as I am concerned, that shouldn''t cause a crash -and indeed doesn''t
on my machine. Maybe you should post the full code of your problem (perhaps
you have a physical memory problem on your machine?).
"Gnik" <Gn**@discussions.microsoft.com> wrote in message
news:A7**********************************@microsof t.com...
我创建了一个带有一些大字符串常量的C#应用​​程序,每当我尝试构建解决方案时,编译器崩溃时都没有错误消息。在进一步分析时,当字符串常量大约为2100字符时,似乎会出现问题。我尝试将常量声明更改为
字符串
变量声明,它工作正常。

任何想法?

以下代码可用于重现该错误:

常量字符串TEST =
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0& QUOT;
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 012345 67890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" <无线电通信/> +
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+ <无线电通信/>" 1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0" ;;

关于
Gn ik
I created a C# application with some large string constants and whenever I
try to build the solution the compiler crashes with no error message. On
further analysis the problem seems to occur when the string constant has
around 2100 character. I tried changing the constant declaration to a
string
variable declaration and it works fine.

Any ideas?

The following code can be used to reproduce the error:

const string TEST =
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0"
+
"1234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 0";

Regards
Gnik




这篇关于大字符串常量会导致C#编译器崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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