This post was kindly contributed by SAS from Out in Left Field - go there to comment and to read the full post. |
Well, I finally made progress on getting my dynamic WPF add-in working. This was in large part to Chris Hemedinger helping out with some questions. What I have learned, I want to share so it is not lost.
WPF works fine with EG except for some graphics issues found when the form is displayed in EG. Not a major issue, a minor one.
The main thing is that it works, runs dynamically using web services on the backend, uses MEF (very cool Framework), and saves us a lot of effort.
Here are some of Chris’ suggestions.
How to debug
To be effective at debugging, you need a professional version of Visual Studio. The Express editions don’t allow you to debug an application unless you built that app (the EXE) with Express.
Assuming that you have the a Pro version, you can use this approach:
– Copy the DLL and PDB (symbols) file into the directory where you are putting Custom tasks.
– Start EG as normal, see the custom task in the Add-Ins menu.
– Before you launch the task, use Visual Studio to attach to the process. With your add-ins project loaded, select Debug->Attach to Process. Find SEGuide.exe and attach.
– Set breakpoints in your add-ins code as needed. You can also select Debug->Exceptions, check “Break when exception is thrown” for managed code.
I don’t recommend throwing exceptions from your task unless you also have other code that will catch the exception. If you allow an exception to bubble up to the SEGuide.exe app, it won’t be good for your end user. Potentially work will be lost in the project. It’s best to catch the exceptions that you can control/react to, and contain them in your add-in.
Adding Nodes Programmatically
To prevent the task from appearing in the process flow, implement it as a modeless window and return ShowResult.Cancel immediately after your task window is displayed. I think the catalog explorer example does this, as does the SAS Macro Viewer example. You will have to add logic to guard against project changes (while your task is running) and re-entrant logic (prevent more than one instance of your task per session).
Now, to add a program node to the project – that’s trickier. If you create a program file (.SAS file on disk), you can trick EG into opening it in the current session. See the “Program Manager (C#)” example that you can find here:
Beyond that, there is not a supported method for creating a new program node (or any node) programmatically via the task APIs.
This post was kindly contributed by SAS from Out in Left Field - go there to comment and to read the full post. |