views:

641

answers:

1

I'm building a visual studio add-in. I copy a solution and do various things to the files inside its and the folder structure. I then load it into visual studio and proceed to load a list of predefined files however when I do this I get an exception and a message saying the files cannot be access for they are in a zombie state.

Here is my code for opening and loading in my Connect.cs

    public void OpenCodeFile(String file)
    {
        try
        {
            _applicationObject.Documents.Open(file, Constants.vsViewKindCode, false);
        }
        catch (System.Exception e)
        {
            System.Console.Out.WriteLine(e.Message);
        }
    }

    public void OpenSolution(String file)
    {
        _applicationObject.Solution.Open(file);
    }

 private DTE2 _applicationObject;
 private AddIn _addInInstance;
+2  A: 

I fixed my problem with the following code:

    public void OpenCodeFile(String file)
    {
        try
        {
            _applicationObject.ExecuteCommand("File.OpenFile", file);
        }
        catch (System.Exception e)
        {
            System.Console.Out.WriteLine(e.Message);
        }
    }
Tom J Nowell