1 (edited by MadHatter 2006-09-21 17:05)

Topic: anybody w/ visual studio 2003 can you test this?

I know this isnt php nor pun related, but I'd assume somebody out there has a copy of visual studio that you could fire up really quick.

this is driving me crazy.  it only happens in visual studio .net 2003 (Im using enterprise arch. version.  I cant reprduce it in visual studio 2005 team suite version)

can sombody debug this in vs 2003 and let me know what happens:

1. create a C# console app
2. paste in the following code in your main:

string s = "abcdefghijkLMNOPQRSTUVWX";
byte[] b = System.Text.Encoding.UTF8.GetBytes(s);
Console.ReadLine();

3. set a break point on the last line (Console.ReadLine()).
4. start in debug mode (let it hit the breakpoint)
5. bring up the memory window (CTRL+ALT+M, 1) and type s in the address box (1)
6. highlight System.Text.Encoding.UTF8.GetBytes(s) and bring it up in the quick watch window by right clicking on the highlighted text and choosing the quick watch menu item (2)

What happens for me:
(1) Shows unknown location (all ? marks)
(2) shows a 25 byte array starting w/ [0] = 24, [1] = 0, [2] = what [0] should have, and from this point on, its the original truncated byte[]

if I follow these exact same steps in 2005 I get what i'd expect, where (1) shows the memory contents of s, and (2) shows the encoded (24 byte length byte array) of s.


in 2003 if I pin s:

string s = "abcdefghijkLMNOPQRSTUVWX";
GCHandle sh = GCHandle.Alloc(s, GCHandleType.Pinned);
IntPtr sp = sh.AddrOfPinnedObject();

then type sp into the address box of the memory window I get what I'd expect to get by typing in s.


If you try it, post your results (do you get the same wrong thing I do?)

thanks,
MH

Re: anybody w/ visual studio 2003 can you test this?

Sorry, only have 2005 sad

Re: anybody w/ visual studio 2003 can you test this?

I was trying to fix a bug where a 24 character string that was stored in a database was being UTF8 decoded into a byte array and used as the key in a triple DES dectyption process.  I was getting an error that the key was invalid for the algorithm.  192 bit keys are allowed in 3DES so I was trying to chase down the problem which led me to this...

the app is an asp.net webservice in 1.1 and I only have 2.0 at home.  when I went home yesterday and tried working on it there, I could never reproduce it. which led me to this bug demo.

very odd.