Question

So I just upgraded from 2010 to 2013 and there is a part of my code that isn't working anymore and it's looking like it's because there are too many characters in the string.

The string I am trying to pass has a length of 120,000 but I'm pretty sure the maximum is supposed to be 1,073,741,823

If i leave it all one string the object is never created at run time - not meaning that the string = nothing but that the string is never created in the first place.

If I break the string up into two equal parts manually, both strings are created and are recognized.

However, if I try to create another string out of both parts, the new string = nothing.

I never had a problem with this is 2010 and I don't see any information about it anywhere on the internet.

Any help would be greatly appreciated, Thanks.

Was it helpful?

Solution

Less of an answer... more of a confirmation that crazy stuff is happening on your machine.

I got a longString by using the "!gAS15169" query on http://radb.net/query/.

I tried initializing the longString variable in a brand new C# project in VS2013 and it seemed to build and run just fine.

public class Program
{
    public static void Main(string[] args)
    {
        string longString = "66.249.64.0/20 ***";
        string greeting = "Hello World!";
        Console.WriteLine(greeting + " " + longString);
        Console.WriteLine("longString.Length = " + longString.Length);
    }
}

*** I couldn't include the entire string in this answer because SO has a limit of 30K characters in a post.

The output of the Length line is:

longString.Length = 74363

This isn't as long as you described in the question though, you said you had a string that was 10K characters. Either way, it shouldn't matter because the maximum length for a string in .NET (VB or C#) is just over 2 billion characters.

Also, I am running this on a 64bit PC and the C# project was set to build for "Any CPU".

I don't know why it isn't working for you but it should.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top