开发者

LinqPad just crashed on me. Is my code anywhere on the disk?

开发者 https://www.devze.com 2023-01-19 12:44 出处:网络
I crashed LinqPad while crafting something slightly less than trivial. I don\'t want to restart it until I\'m sure that won\'t jeopardise recovering my work (if this is possible). My question is: Does

I crashed LinqPad while crafting something slightly less than trivial. I don't want to restart it until I'm sure that won't jeopardise recovering my work (if this is possible). My question is: Does LinqPad write temp files anyware that might still contain the code I wrote?

For posterity, here's a test case that crashes LinqPad every time (also posted to LinqPad forum):

void Main()
{
    Crasher.Crash();
}
class Crasher
{
    public static void Crash()
    {
        var a=0;
        Crash();
     开发者_如何学Python   a++; //let's get something in the tail so compiler 
             //doesn't optimise tail recursion and prevent
             //stackoverflow
    }
}


Before the crash did you happen to run it once? If so it would've been compiled and should be available as a dll that you can open with .NET Reflector.

Check the LINQPad temp folder, for example: C:\Documents and Settings\username\Local Settings\Temp\LINQPad. Sort the files by modified date then check a few of the dlls in Reflector till you find your query. It probably won't resemble your query exactly but it should be good enough for you to salvage your code.

UPDATE: an auto-recovery feature has been added to LINQPad (Beta, at the time of this writing). To my knowledge it has been available in the Beta version as early as v4.28.3. Get the beta to take advantage of it, or it may already be in the release version for future readers of this post. If LINQPad is launched after it crashes it will throw a dialog up asking whether or not you would like to recover unsaved queries.

0

精彩评论

暂无评论...
验证码 换一张
取 消