简体   繁体   中英

Is there a Limit to the Number of characters that a variable / property name can be?

I have to apologize the question does not fully address my issue. This is a C# issue dealing with passing a UDT object to ac# webservice. The client end is a windows mobile forms application.

I currently have a UDT that I personally defined and have now added a new member to (a variable named schedulerRecordCount, the property is named SchedulerRecordCount). Before adding this new member I was able to pass an instance of this object to a web service method without issue. After adding the new member I was unable to get a response from my web method. After calling the webmethod and passing the object I would get an exception that says "unable to read from the transport connection".

I tried many things to trouble shoot, and in a last-ditch effort, I shorted the variable name to schedRecCnt and the property to SchedRecCnt. This did the trick. As a note, all of the other members of this UDT are of type String (as well as my new member).

Does anyone know of a limitation to the number of characters that a variable can have when being passed inside of a UDT to a web method?

There is of course some limit to the length of identifiers, but you are certainly not even close to it. I don't know the exact limit, but perhaps 1000 characters or so.

You might however have reached the limit for the total size of the message that is returned. That would fit with how shortening the property name makes it work, as that would shorten the total length of the message also.

In the settings for the SOAP binding in web.config on the client, check the value of the MaxReceivedMessageSize property, and increase it if needed.

There is no limit imposed by C# specs but Visual Studio IDE will colorize only

511 characters in C# and 1023 characters in VB.Net (leaving other characters black).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM