Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Hosting App-Domain from Visual Studio - VS is Unloading silently

Hosting App-Domain from Visual Studio - VS is Unloading silently

Scheduled Pinned Locked Moved .NET (Core and Framework)
visual-studiohelpcsharphosting
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    debnarayan
    wrote on last edited by
    #1

    Hi, I am trying to create a Visual Studio 2005 Add in, that should call an Winform application to gather some info from user. I have hosted the Form code in a new AppDomain and have obtained the required fields back via AppDomain.SetData and GetData methods. Problem is, VS is unloading silently, even if the WinForm did not throw any exception. Here is the code for the Exec method:

    public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
    {
    handled = false;
    if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
    {
    if(commandName == "TestVSAddIn.Connect.TestVSAddIn")
    {

                    AppDomain wizardDomain = null;
                    try
                    {
                        if (String.IsNullOrEmpty(this.applicationWizardAssemblyName) || !File.Exists(this.applicationWizardAssemblyName))
                            throw new InvalidOperationException("Installation error.");
    
                        if (wizardDomain == null)
                        {
                            AppDomainSetup wizardDomainSetup = new AppDomainSetup();
                            wizardDomainSetup.ApplicationBase = applicationWizardAssemblyPath;
                            wizardDomainSetup.PrivateBinPath = applicationWizardAssemblyPath;
                            wizardDomain = AppDomain.CreateDomain("WizardDomain", null, wizardDomainSetup);
    
                            wizardDomain.SetData("RunningFromVS", true);
                        }
    
                        wizardDomain.ExecuteAssembly(applicationWizardAssemblyName);
    
                        if (wizardDomain.GetData("OpenInVS") != null && wizardDomain.GetData("SolutionPath") != null)
                        {
                            bool openInVS = Convert.ToBoolean(wizardDomain.GetData("OpenInVS"));
                            string solutionPath = Convert.ToString(wizardDomain.GetData("SolutionPath"));
    
                            if (\_applicationObject.Solution.IsOpen)
                            {
                                \_applicationObject.Solution.Close(true);
                            }
    
                            \_applicationObject.Solution.Open(solutionPath);
                        }
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            Logger.LogThis("Error
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups