6

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();
        a++; //let's get something in the tail so compiler 
             //doesn't optimise tail recursion and prevent
             //stackoverflow
    }
}
spender
  • 117,338
  • 33
  • 229
  • 351

1 Answers1

8

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.

Ahmad Mageed
  • 94,561
  • 19
  • 163
  • 174
  • 2
    Great news. To be fair, it's never crashed on me again. Joe kindly explained to me that stackoverflow is one error that he cannot prevent from taking down LinqPad but that my plight had inspired him to include this feature. LinqPad is a rarity among products where I don't feel stung when I become a paid up user. – spender Dec 02 '10 at 16:00
  • 1
    Install Jetbrains dotPeek and browse for the last modified assembly @ C:\Users\Name\AppData\Local\Temp\LINQPadX. – paul-2011 Jul 22 '21 at 14:31
  • 1
    I just had LINQPad crash in a weird way that subverted the auto-recovery feature. DotPeek wasn't great at reverse-engineering the C# 9 structures like records, but I used the ILSpy app that comes with LINQPad, and was able to recover most of my work. – StriplingWarrior Jul 29 '21 at 21:43