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