locked
RPC_E_SERVERCALL_RETRYLAYER error is seen while creating VisualStudion solution programatically RRS feed

  • Question

  • Hi,

    I am trying to create Visual Studio solution progrmatically. Following is the code :

    Dim type As System.Type = System.Type.GetTypeFromProgID("VisualStudio.DTE.10.0")
            Dim obj As [Object] = System.Activator.CreateInstance(type, True)
            Dim dteObj As EnvDTE80.DTE2 = DirectCast(obj, EnvDTE80.DTE2)
            Dim projectName As String = Path.GetFileNameWithoutExtension(projectFilePath)
            ' Register the IOleMessageFilter to handle any threading errors.
            MessageFilter.Register()
            Dim projectSolution As Solution2 = DirectCast(dteObj.Solution, Solution2)
            Dim templateLocation As String = projectSolution.GetProjectTemplate(solutionType, "CSharp")
            Dim projectDirectoryPath As String = Directory.GetParent(projectFilePath).FullName
            If Not Directory.Exists(projectDirectoryPath) Then Directory.CreateDirectory(projectDirectoryPath)
            projectSolution.Create(projectDirectoryPath, projectName)
    		projectSolution.AddFromTemplate(templateLocation, projectDirectoryPath, projectName, isProjectToBeAddedToNewSolution)
            projectSolution.SaveAs(solutionPath)
            projectSolution.Close()
            
            dteObj.Quit()
            'and turn off the IOleMessageFilter.
            MessageFilter.Revoke()

    I have referred to http://msdn.microsoft.com/en-us/library/ms228772.aspx link and even implemented IOleMessageFilter. I am registering the message filter prior to solution creation and unregistering it after the solution is closed.

    Still I see RPC_E_ServerCall_RetryLayer exception.


    sirisha

    • Moved by Siddhartha Pandey - MSFTMicrosoft employee Friday, May 4, 2012 6:25 AM Not related to Codeduitest. Moving to other forum to get better response. (From:Visual Studio UI Automation Testing (includes CodedUI))
    Friday, May 4, 2012 6:19 AM

Answers

  • Is the main thread in your application an STA thread? Message filters can only be applied to STA threads. By default managed threads are not, try applying the STAThread attribute to your main method.

    Ryan

    Friday, May 4, 2012 5:31 PM
  • Debug it, and verify that the native APIs are returning a zero (S_OK) value. And as Ryan suggested, make sure the app is STA threaded.

    Sincerely,


    Ed Dore

    • Marked as answer by lucy-liu Thursday, May 17, 2012 6:04 AM
    Saturday, May 5, 2012 1:35 AM

All replies

  • Is the main thread in your application an STA thread? Message filters can only be applied to STA threads. By default managed threads are not, try applying the STAThread attribute to your main method.

    Ryan

    Friday, May 4, 2012 5:31 PM
  • Debug it, and verify that the native APIs are returning a zero (S_OK) value. And as Ryan suggested, make sure the app is STA threaded.

    Sincerely,


    Ed Dore

    • Marked as answer by lucy-liu Thursday, May 17, 2012 6:04 AM
    Saturday, May 5, 2012 1:35 AM
  • Molden/Dore,

    I will try what you have suggested and get back to you people with the status ASAP.

    Thanks,

    Sirisha


    sirisha

    Monday, May 7, 2012 12:18 PM
  • Hi Sirisha,

    Do you have any update about this issue?

    Please feel free to let us know.

    Thank you for your understanding!


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us

    Friday, May 11, 2012 7:19 AM
  • Hi Lucy,

    That worked fine for me. Thanks for the help.

    Regards,

    Sirisha


    sirisha

    Tuesday, May 29, 2012 10:49 AM