Ask a questionAsk a question
 

AnswerAccessViolationException when doing IvsWindowFrame.show()

  • Wednesday, November 04, 2009 5:41 PMkved Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I have a desginer that i am trying to open and this designer has an embedded editor. Following is the code:

    IVsUIShellOpenDocument shell = (IVsUIShellOpenDocument)DesFMPkg.Instance.GetService(typeof(IVsUIShellOpenDocument));

    IOleServiceProvider sp = (IOleServiceProvider)DesFMPkg.Instance.GetService(typeof(IOleServiceProvider));

    Guid editorType = GuidList.guidMultiViewEditor;

           Guid logicalView = GuidList.guidDesignView;

    int hr;

           if (des.HasCodeEditorView)

           {

              IVsSolution vsSolution = (IVsSolution)DesFMPkg.Instance.GetService(typeof(SVsSolution));

              object obj;

              hr = vsSolution.GetProperty((int)__VSPROPID.VSPROPID_IsSolutionOpen, out obj);

              if (!(bool)obj)

               {

                  hr = vsSolution.CreateSolution(string.Empty, string.Empty, (uint)__VSCREATESOLUTIONFLAGS.CSF_TEMPORARY);

                }

             }

    this.m_designer = des;

            string caption = "";

    // Find the item id assigned to this document by the project.

    uint pitemid = VSConstants.VSITEMID_NIL;

    string moniker = des.Moniker;

    VSVirtualProject project = DesFMPkg.Instance.GetService(typeof(VirtualProject));

    IVsUIHierarchy hier = project as IVsUIHierarchy;

    IVsProject proj = project as IVsProject;

    hr = project.AddDesigner(des, out pitemid);

    ErrorHandler.ThrowOnFailure(hr);

    hr = shell.OpenSpecificEditor(

    (uint)0,

    moniker,

    ref editorType,

    null,

    ref logicalView,

    caption,//node.Caption,

    hier,

    pitemid,

    System.IntPtr.Zero,        

    sp,

    out editorFrame);

    if (ErrorHandler.Succeeded(hr)) {

    editorFrame.SetGuidProperty((int)__VSFPROPID.VSFPROPID_InheritKeyBindings, ref GuidList.guidCmdUI_TextEditor);

    if (this.DontShowWindow == false)

    rrorHandler.ThrowOnFailure(editorFrame.Show());

    }

    on the EditorFrame.show, i get AccessViolationException. "Attempt to read to write protected memory".
    Cam someone help..

    •  

Answers

  • Monday, November 09, 2009 9:50 PMDmitry GoncharenkoMSFT, OwnerUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,

    Could you provide more detailes about the exception like the callstack it for example? Better yet, could you capture a minidump file for the exeption and create a Connect Bug with the appropriate repro steps?  Ideally, you can attach your project to see if we can try to repro the exception as well.

    Thanks!
    Dmitry.

All Replies

  • Monday, November 09, 2009 9:50 PMDmitry GoncharenkoMSFT, OwnerUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,

    Could you provide more detailes about the exception like the callstack it for example? Better yet, could you capture a minidump file for the exeption and create a Connect Bug with the appropriate repro steps?  Ideally, you can attach your project to see if we can try to repro the exception as well.

    Thanks!
    Dmitry.