views:

1346

answers:

3

Hi folks, I have a dump of a windows service i made. The exception is that my code can't move a file (for some reason). Now, in my code there's a number of places where i move files around the filesystem. So, using Windbg, i'm trying to see the code where the exception occurs.

here's my !clrstack dump..

0:016> !clrstack -p
OS Thread Id: 0xdf8 (16)
Child-SP         RetAddr          Call Site
0000000019edea70 0000064278a15e4f System.IO.__Error.WinIOError(Int32, System.String)
PARAMETERS:
    errorCode = <no data>
    maybeFullPath = <no data>

0000000019edead0 0000064280181ce5 System.IO.File.Move(System.String, System.String)
PARAMETERS:
    sourceFileName = <no data>
    destFileName = <no data>

0000000019edeb50 0000064280196532 MyClass.Foo.DoSomeStuffInHere(System.String)
PARAMETERS:
    this = 0x0000000000c30aa8
    filePathAndName = 0x0000000000d1aad0

now, this helps a lot...

0:016> !do 0x0000000000d1aad0
Name: System.String
MethodTable: 00000642784365e8
EEClass: 000006427803e4f0
Size: 88(0x58) bytes
(C:\WINDOWS\assembly\GAC_64\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)
String: C:\BlahBlahFolder\FooFolder\4469.jpg
Fields:
-snipped-

So i've figured out the file which failed to be moved. kewl. But i just want to see the code in this method MyClass.Foo.DoSomeStuffInHere(System.String) which calls File.Move(..). That method has lots of File.Move .. so i could put try / catches / debug / trace information .. but i'm hoping to be more efficient by using Windbg to help find this problem.

Any thoughts?

A: 

It sounds like this is a run-time exception that might occur in the field (or at least in "real" use, if you're not releasing it to customers). If this is the case, it's probably worth your time to log the file moves and/or catch the exceptions, because the problem will probably happen again ... at the most inconvenient time ... in front of the wrong people.

Even if it's a catastrophic error, it's always better to anticipate it and fail gracefully than to crash. If a customer's involved, it looks that much less catastrophic, and it's always helpful in debugging.

Good luck!

Adam Liss
Thanks adam for the comment .. but that doesn't help me use Windbg to list the code where the exception is being thrown. I have a number of ideas to help resolve this ... but this is a question about how to use Windbg :)
Pure.Krome
That was NOT an answer.
TheSoftwareJedi
Thanks for your analysis ... on the other hand, PK was diligent enough to suggest a tentative course of action, and assuming there are dollars at stake, I shared my experience. If that has no value, please suggest a solution that helps.
Adam Liss
+2  A: 

You cannot get the exact line of code, unless the application was deployed in debug mode. And if that were the case, I believe it would be showing them in the !clrstack call.

TheSoftwareJedi
thanks mate :) it's in release mode. I didn't want to say that because i didn't want to influence any answers, in case that was not the answer.sweet dude. i'll try and rebuild in debug mode, release etc. cheers mate (and i was afraid that someone would say that was the prob).cheers!
Pure.Krome
np. you can also just refactor it so that the many calls to File.Move are in different methods...
TheSoftwareJedi
+1  A: 
AaronBa
Thanks heaps arron for the post! excellent! I'll have to give this a try when i get some spare time .. but this is a good reference post for when this will happen, again, in the future :)
Pure.Krome