Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Why does a watch or quick watch on string.SubString() not work in VS.Net 2003

Posted on 2004-11-18
21
Medium Priority
?
451 Views
Last Modified: 2008-02-01
I an using ASP.Net with C# codebehind. I have the following code behind an aspx Page. The code runs successfully.
private void Button1_Click(object sender, System.EventArgs e)
{
      string a;
      string b;
      a = "abcdefghijklmnopqrstuvwxyz";
      b = a.Substring(2); //breakpoint on this line
}

My issue is that when I try to look at the value of a.Substring(2) in the IDE while debuging.

I have a breakpoint set at 'b = a.Substring(2)'. If i try ?a in the immediate window or put a watch on a i get "abcdefghijklmnopqrstuvwxyz" as expected. If i do the same with b I get null as expected. If I try ?a.Substring(2) in the immediate window or put a watch on a.Substring(2) I expect to receive "cdefghijklmnopqrstuvwxyz", however I get an error - "error: 'a.Substring' does not exist"

I have tried the same code in vb code behind and the IDE works as expected!

Why can I not check the value or variable.SubString() in the IDE for C# code?
I am looking for a definitive reason why?

0
Comment
Question by:stumpy1
  • 13
  • 5
  • 3
21 Comments
 
LVL 28

Expert Comment

by:mmarinov
ID: 12616252
Hi stumpy1,

try to put a.SubString(2) not a.Substring(2) :) c# is case sensitive

Regards!
B..M
mmarinov
0
 
LVL 5

Author Comment

by:stumpy1
ID: 12616420
Its not a code sensitivity thing. The code compiles and runs perfectly, 'does exactly as i says on the tin'.
The code would throw compile error otherwise. It actually throws a compile error if you try a.SubString(2);

Its when I try and view what the result of a.Substring(2) is going to be, through the immediate window or through a watch that it refused with the error message.

Its definatly 1 of those niggling problems. As I said, the code runs properly, I just want to try and figure out why the IDE wont les me watch the expression
0
 
LVL 5

Author Comment

by:stumpy1
ID: 12616711
I have the same problems with several other functions

?a.ToLower() returns
error: 'a.ToLower' does not exist

?a.ToString() returns
error: 'a.ToString' does not exist

etc. etc. I am using Visual Stidio Architect Edition 2003.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Author Comment

by:stumpy1
ID: 12655979
mmaronov, thanks for your suggestion. I think I will probably have to delete this question. I am going to leave it open for another while to see if I get any other input.
I will post another comment before I delete anyway.
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 12656151
stumpy1,

i've tried a lot of times and ways and can not come with clear solution
the easy way ( but just for debuging ) is to use another variable - i know it sounds crazy but if you want to check your code - this is a solution

also, very sorry for the big delay

B..M
mmarinov

P.S.: i'm ok with closing the question. no problems
0
 
LVL 5

Author Comment

by:stumpy1
ID: 12656703
mmarinov,
No probs. This question is more out of curiousity than anything else. I have workarounds for it already, its just 1 of those things that eats away at my curiousity.

The really odd thing is that the watch/immediate window works for VB.Net code but not for C#.Net code inside the VS IDE.

Thinking about it again, It must be a limitation of the C# compiler or something like that.

Im going to leave the question open for another while anyway, Will probably just get it PAQ'd as opposed to deletion in case anyone else has similar
0
 
LVL 28

Accepted Solution

by:
mmarinov earned 600 total points
ID: 12658626
Yes, it could be that reason
Vb is much on the top than c# :)

B..M
mmarinov
0
 
LVL 5

Author Comment

by:stumpy1
ID: 12708252
I posted a 20 point link question in the ASP.Net and .Net TA's to see if someone else has anything else on this topic.
0
 
LVL 101

Assisted Solution

by:mlmcc
mlmcc earned 450 total points
ID: 12708510
I haven't tried this in the environment but I suspect the debugger cannot run the method in question

mlmcc
0
 
LVL 5

Author Comment

by:stumpy1
ID: 12708640
mlmcc,
The debugger can do it with VB.Net code as a watch or in the immediate window but not when its C# code, even if the VB and C# projects are inside the same solution.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12712531
That may be because VB gets interpreted when run in debug mode while C# is compiled with debug information added.

mlmcc
0
 
LVL 5

Author Comment

by:stumpy1
ID: 12715757
Would you have any links etc. about this difference between how VB.Net and C#.Net are treated in the VS IDE? Currently you cannot make changes on the fly using VB.Net while in run mode but this is going to change with .Net 2.0 and VS 2005.

I have done a bit of searching on the web about this but havent found any explanation *per-say* yet.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12723354
I don't have any such information.  We are still using VB6 with no intention of moving to the .Net so I haven't done any real research except what I read here.

mlmcc
0
 
LVL 5

Author Comment

by:stumpy1
ID: 12735547

I am tempted to post a new link in the ASP.Net TA and up the points to see if I can generate some more information about this, there must be someone in this forum that knows the definitive answer to this
or
should I just PAQ the Q?
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12742004
Just be careful of the 500 point max on a question or group of the same question.

mlmcc
0
 
LVL 5

Author Comment

by:stumpy1
ID: 12752887
I posted a new pointer link in the ASP.Net TA. I will probably just leave this open for another few days to see if anyone more feedback and then PAQ it for future reference.
0
 
LVL 5

Author Comment

by:stumpy1
ID: 12765046
I found a little snippet on http://weblogs.asp.net/andypennell/archive/2004/02/03/66949.aspx that may be related,
Andy Pennell stated: The VS 2003 C# EE does not allow you to call methods on primitive types (eg string). We fixed it in VS "Whidbey".

I cant believe there isnt an easily found answer for this out there, amazing!
0
 
LVL 5

Author Comment

by:stumpy1
ID: 12782209
I found another mention by Craig Neable
at http://msdn.microsoft.com/chats/transcripts/mobileembedded/embedded_041703.aspx

From the page:
Host: Craig (Microsoft)
Q: Some function like String.SubString() does not work in immediate window during debug time in NETCF, is it a known bug?
A: Not that we know of, but we always love to hear about things we can fix...:-)

0
 
LVL 5

Author Comment

by:stumpy1
ID: 12868230
I posted a question on a different forum to see if I would get any feedback but alas, nothing so far. I will keep posted
0
 
LVL 5

Author Comment

by:stumpy1
ID: 12877863
Im closing out this question as it seems that the information is unavailable anywhere I look, its almost like theres a conspiricy theory trying to cover up the fact that the problem exists....

Sorry about the B, just didnt get definitive answer/reason
Thanks for your input all the same......
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12880764
Glad i could help

mlmcc
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month20 days, 17 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question