Is it possible to Edit and Continue in Visual Studio 2010 without pausing execution?

前端 未结 5 510
梦毁少年i
梦毁少年i 2020-12-03 03:32

I recently watched a bit of Notch\'s Ludum Dare live stream. He uses Eclipse\'s hotswap feature extensively while he works on his game. (here is a video of what I am referri

5条回答
  •  生来不讨喜
    2020-12-03 04:26

    i can tell you how, but you arn't going to like it:

    1) run your game executable in a visual studio instance (game.exe --> vsInstanceA)

    2) code your modifiable code in a seperate dll, using a seperate visual studio instance (modifiable.dll --> vsInstanceB)

    *note that doing this lets you compile your modifiable.dll, thus doing compile time error checking, etc.*

    ... and now is where it get's tricky ...

    3a) game.exe needs to reference the modifiable.dll. NOT the .vcproj, the actual dll

    3b) when you hit a "magic key" (have game.exe look for a key-press), have game.exe unload the modifiable.dll, and reload it. You can easily do this via the Assembly and AppDomain classes provided in mscorlib. Of course this means you need to unload any dependant systems in game.exe.

    note, there's a lot of hand-waving in this 3b) section, it's quite a lot of work but pretty straight forward (example google search: https://www.google.com/search?q=dynamic+load+dll+.net)

    ... and after that, you are good to go ...

    3-alt) some other choices if 3b) doesn't suit you:

    • you can invoke msbuild.exe to rebuild modifiable.dll when you press "magic key"
    • you can use the CSharp compiler dll's to dynamically recompile each class instead of the entire modifiable.dll

    but unfortunatly, in my 10+ years of .net development, this is the only way, unless someone has created a 3rd party product to do it (IE: they do what i mentioned, for you)

提交回复
热议问题