mardi 25 octobre 2011 19:09
In the C# Interactive window, is it possible to refer to an object as it is being debugged in the Visual Studio code editor?
My rationale is the following. I would like to explore a WPF project using the Interactive window. But my app throws several exceptions when I attempt to instantiate it directly in the C# Interactive window via:
var app = new myApp();
And calling the static App.Main() likewise throws the same exceptions.
But my application runs fine when launched either via F5 from Visual Studio or by double-clicking on its executable. Consequently I'm not really sure why it doesn't run when it's launched via the C# Interactive window. One problem is that EntityFramework pleads ignorance of the connection string and a copy of the App.Config file has to be manually dropped in the same folder as the running .EXE.
Hence, it would be helpful to attach to a running application as it is being debugged. Is this even possible? Failing that, is there guidance available regarding how to Interactively instantiate an MVVM-style WPF app?
Toutes les réponses
mardi 25 octobre 2011 19:54Auteur de réponse
No, it's not possible to "attach" to an application under debugger with the CTP.
The interactive session runs in a separate process (InteractiveHost.exe) that doesn't automatically load .config files of your app as you noticed. Something we'll definitely consider supporting along with improving overall experience with WPF apps.
mardi 25 octobre 2011 20:11Propriétaire
Hi Calvin - Regarding the exception that you are seeing - you may want to glance through the "Seeding the Interactive Window from a WPF Project" walkthrough (which can also be accessed from the below link in the Getting Started guide on your machine).
There is some text in the below section that seems relevant -
I am not sure whether this is the reason for the exception you are seeing - but it certainly seems worth a try...
Hope this helps.
Shyam Namboodiripad | Software Development Engineer in Test | Roslyn Compilers Team
- Modifié Shyam NamboodiripadMicrosoft Employee, Owner mardi 25 octobre 2011 20:16
mardi 25 octobre 2011 20:28Propriétaire
Yes, Shyam correctly described the culprit. I learned this while developing the walkthrough :-). We have an internal bug / work item to look into getting the context right for looking up resources in the project's output directory. Please look through the walkthrough that Shyam points out.
As Tomas said, we aren't currently working on the scenario of hitting F5, then attaching the REPL to the running process. Of course, having all the power of the REPL in this scenario would be cool, but we first want to nail the exploratory, interactive development support, where you can redefine functions and classes readily without the .NET/EnC constraints.
mardi 25 octobre 2011 20:28
Thanks for the recommendation Shyam. Actually I did try that approach and I was able to instantiate a window. But I'm not able to get my MVVM-style model wire up by simply instantiating a window. I'm using Caliburn.Micro with MEF as the IOC container and I would like Caliburn's bootstrapper to wire up the shell.