DTE in VSIX getting Access Denied

0

I am working in a Visual Studio Extension that take the project in the Solution that the user have clicked, I can take the project, add files from strings in this project, but when the DTE finishes to adding the files and all work is finished and the user try to build that project, the DLL continue to be used by the VS, I have checked all info about this problem and discovered that I need to set the UserControl to False. I tryed to set it in the command, I have created an Editor Classifier to make it false inside of the classifier, I tryed to use my Visual Studio with Admin Right and all of I have take is this message: System.UnauthorizedAccessException: 'Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))'

Today I am trying it inside a MenuItemCallback like this:

        {
            IntPtr hierarchyPointer, selectionContainerPointer;
            Object selectedObject = null;
            IVsMultiItemSelect multiItemSelect;
            uint projectItemId;

            IVsMonitorSelection monitorSelection =
                    (IVsMonitorSelection)Package.GetGlobalService(
                    typeof(SVsShellMonitorSelection));

            monitorSelection.GetCurrentSelection(out hierarchyPointer,
                                                 out projectItemId,
                                                 out multiItemSelect,
                                                 out selectionContainerPointer);

            IVsHierarchy selectedHierarchy = Marshal.GetTypedObjectForIUnknown(
                                                 hierarchyPointer,
                                                 typeof(IVsHierarchy)) as IVsHierarchy;

            
            if (selectedHierarchy != null)
            {
                ErrorHandler.ThrowOnFailure(selectedHierarchy.GetProperty(
                                                  projectItemId,
                                                  (int)__VSHPROPID.VSHPROPID_ExtObject,
                                                  out selectedObject));
            }

            Project selectedProject = selectedObject as Project;


            selectedProject.DTE.UserControl = false;
}```

And when the code reach in the last line I take that error. Someone know what's happens?
c#
vsix
envdte
asked on Stack Overflow Jul 29, 2020 by InfJ • edited Jul 29, 2020 by InfJ

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0