Please try this C++/COM/C# sample for VSTA 2.0 on how to:
--load/unload different macro addins/projects
--'show macros' whether the assembly is loaded in memory or not (ReflectionOnly).
Sample demonstrates:
1. 'Load VCF' loading and unloading macro addins and their projects from a single compressed file in any folder.
//unzip single (unconsidered) VCF file to ProjectsWorkingDirectory
m_pVCF->UnzipVCF(std::string(pszVCFPath));
//Load single appaddin assembly from ProjectsWorkingDirectory
applicationIntegration->LoadVCF(CComBSTR(pVCFPath));
2. Unified naming: the .vcf name, the assembly name, the assembly project name, add-in project folder and add-in assembly folder (they all have the same name).
3. 'Edit VCF' Out-of-process project load, edit, build, debug of (sample demonstates with loaded Addin1 or loaded Addin2).
4. 'Show Macro' - shows macros in the add-in.
If addin is loaded, it examines loaded instance for "macro" methods
If addin is not loaded it extracts and examines using 'ReflectionOnly' so that addin needn't be loaded.
These parts of the sample are worth noticing:
1. Single RegisterExternalDebugHost for entire session
ideintegration.cs:
internal void Connect(Integration integration)
{
this.reloadInProc = true;
this.integration = integration;
this.hostDebugUri = ExternalDebugging.RegisterExternalDebugHost((IExternalDebugHost)this, "ShapeAppMFC");
}
I hold one this.hostDebugUri string for the entire session and use for every macro project load to establish out-of process debugger connection (see SetMacroProjectDebugInfo()).
2.
The sample demonstrates the sequence needed to repeatedly load and debug projects in a single session:
RegisterAsDebugHost
LoadVCFProject
ShowIde
OpenMacroProject
buildEvents_OnBuildDone
LoadAddIn In-Process
[.....]
[.....]OnBeforeDebugStarting
[.....]EnsureMacroAddInProcess
[.....]==================>EnsureMacroAddInProcess: Create external process
[.....]OnDebugStarting
[.....]OnDebugStarting: UnloadAddIn
[.....]==================>Unload Addin: ShapeAppMFCAppAddIn1
[.....]OnDebugStarting: LoadAddIn
[.....]==================>LoadAddIn Ex-Process<=================
[.....]OnDebugStopping
[.....]OnDebugStopping: UnloadAddIn
[.....]==================>Unload Addin: ShapeAppMFCAppAddIn1 [skip OnShutdown]
[.....]OnDebugStopping: LoadAddIn
[.....]==================>MacroAddInProcessExiting
[.....]LoadAddIn In-Process
[.....]
UnloadVCFProject
solutionEvents_AfterClosing
ShowIde [Hide]
==================>Unload Addin: ShapeAppMFCAppAddIn1
3. Deterministic add-in unload:
ApplicationIntegration.cs
internal void UnloadAddIn(String name, bool skipOnShutdown)
4. ReflectionOnly macro discovery:
ApplicationIntegration.cpp
internal string[] GetMacroNamesByReflectionOnly(String addInName)
Posted
May 26 2009, 12:47 PM
by
BillL