Visual Studio IDE error - Cannot access a disposed object - visual-studio-2017

I'm getting the following error when trying to open any .cs file in my solution.
I've tried 1) restarting Visual Studio, 2) restarting computer, 3) delete all obj folders, 4) delete all .vs files and folders and still I can't open any files.
Same error message if I double click on the file in solution explorer or use F7.
The files do exist.
I've also tried disabling resharper in case it was that causing the issues, but it doesn't help.
I've also tried navigating to classes using Ctrl+T, entering class name and selecting the class. No error messages, but nothing loads.

This is the error I got when I tried to open an old solution: Cannot access a disposed object. Object name: 'WorkspaceContext'. I found the solution from Refat Eid's blog.
You just need to open the following directory and delete the content there:
%LocalAppData%\Microsoft\Team Foundation\7.0\Cache
Depending on your Visual Studio, you may have a different version number in your %LocalAppData%\Microsoft\Team Foundation. If you are not sure, copy the content to a temp folder first.
Other answers, either upgrading or reinstalling, basically serve the same purpose.

The problem here was that my solution folder was inside my OneDrive folder, which was doing automatic syncing with my OneDrive account.
Moving the solution folders out of the one drive folder made the errors go away.

I have the same issue but in Visual Studio 2019 Community Edition latest update which is Version 16.7.2.
After the update, all of my solutions that was bound in Azure Devops were experiencing problems when I try to checkin with the same error message as OP.
So, I deleted the folder but instead of:
%LocalAppData%\Microsoft\Team Foundation\7.0\Cache
I deleted this instead:
%LocalAppData%\Microsoft\Team Foundation\8.0\Cache
Then re-open my solution and it will rebind automatically after this message box:
In case it didn't rebind. Try to re-open your solution via Team Explorer -> Source Control Explorer and double click the solution directly on the Source Control Explorer.

In my case it was solved by simply restarting the visual studio.

I solved this problem, by re-downloading the vs installer (i apparently deleted my old copy), and telling it to run an update as well.

This is insane. Why should OneDrive synchronization cause this problem?
My Windows 10 system just installed a bunch of new updates today (4/11/2018). Immediately after those updates were installed I was unable to open any of my C# files in VS 2017 (error: Cannot access disposed object). All of these files opened without problem prior to today's updates.
Moving the projects off OneDrive solved the problem, as did opening the files in a previous version of VS (I tried VS 2015).
All of my VS projects are stored on OneDrive, with copies on my local drive. OneDrive claims that all my files are up to date, so I don't understand how this can be related to OneDrive synchronization.
Has anyone else suddenly run into this problem?

In my case, I have the solution file and its folder under OneDrive sync folder. Right click OneDrive system tray and click Settings. Under the Settings tab, uncheck Save space and download files as you use them checkbox (Files On-Demand)

I had the same issue, however after I upgraded to the latest version of Visual Studio 2017 (15.6.7), the error message disappeared, so I could open all files in the solution again. Hope this helps.

In my case this was due to deleting solution configurations which were not immediately saved, just saving all and restarting Visual Studio solved the problem.

In my VS2019. Closed VS. Disable Sync of One Drive Files, and reload project. Problem gone! It definitely seems somewhat related to OneDrive. Even though in my case all files were Sync'ed still pausing it and re-opening VS resolved. It could have been just restart of VS...

I had the same error. My solution is not stored in onedrive, but locally.
the full error message was :
error performing rename. cannot access a disposed object. object name invisibleEditor
the error happened when I renamed first the file from the solution-explorer window then clikced yes, which normally changes the class name as well, however this did not happen.
then when i tried to change the class name the error was thrown.
I restarted VS 2019 Enterprise 16.11.3 few times but that did not help.
I resolved this by:
undoing the renaming of the file in the solution explorer
deleting the .vs folder in my solution directory
deleting all the bin and obj folders in on my projects within then solution.
the renaming was then successful.
the error stack was :
System.ObjectDisposedException : Cannot access a disposed object.
Object name: 'InvisibleEditor'.
at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.InvisibleEditor.get_TextBuffer()
at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.ApplyTextDocumentChange(DocumentId documentId,SourceText newText)
at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.ApplyDocumentTextChanged(DocumentId documentId,SourceText newText)
at Microsoft.CodeAnalysis.Workspace.ApplyChangedDocument(ProjectChanges projectChanges,DocumentId documentId)
at Microsoft.CodeAnalysis.Workspace.ApplyProjectChanges(ProjectChanges projectChanges)
at Microsoft.CodeAnalysis.Workspace.TryApplyChanges(Solution newSolution,IProgressTracker progressTracker)
at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.TryApplyChanges(Solution newSolution,IProgressTracker progressTracker)
at Microsoft.CodeAnalysis.Workspace.TryApplyChanges(Solution newSolution)
at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.ApplyRename(Solution newSolution,IWaitContext waitContext)
at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.CommitCore(IWaitContext waitContext,Boolean previewChanges)
at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.<>c__DisplayClass78_0.b__0(IWaitContext waitContext)
at Microsoft.VisualStudio.LanguageServices.Implementation.Utilities.VisualStudioWaitIndicator.Wait(String title,String message,Boolean allowCancel,Boolean showProgress,Action`1 action)
at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.CommitWorker(Boolean previewChanges)
at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.Dashboard.Commit()
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

Related

Visual Studio 2017 - Access Denied Error on Rebuild

I have a solution I created in Visual Studio 2017. All solution files are stored on a network location, accessed via a mapped drive. Up until earlier this week (April 10, 2018), everything worked fine. I could perform all required functionality.
Now, when I attempt to debug or build the release files, I get the following error:
Unable to copy file "obj\x64\Release\program.exe" to "bin\x64\Release\program.exe". Access to the path 'bin\x64\Release\program.exe' is denied.
The file is completely locked at this point. I can't do anything with it. I've done all of these suggestions found in other posts:
Make sure all instances of VBCSCompiler.exe are killed
Install the latest version of VS 2017
Install version 1.0.8 of Microsoft.CodeDom.Providers.DotNetCompilerPlatform
None of it works. I still get the error.
Now the real strangeness...
After I rebooted my machine the .exe file is removed from the release and debug folders. I can open the solution and rebuild the project successfully at that point, complete with a new, fully accessible .exe file. If I attempt to rebuild right away, with no changes made, the error shows up again.
I have to reboot my machine to release this file. That's hardly efficient.
If I copy the solution locally everything works fine. I don't have any issues.
I'm willing to move to working locally (as I'm sure it's a more advisable approach, but please spare me lectures on that topic) but I'd like to get to the bottom of this, if possible.
Thanks for any help you can offer...

Visual Studio 2017 - Not Able to see Publish Profiles

In my VS 2017, my publish profile is not being listed in the publish section of the VS 2017.
I can run the application with no error but I can't publish it or see and log file saying any error about when I do right click the project and click on publish. And also even if I wanted to create new profile VS just doesn't open create new profile window.
Any guess what might be causing this?
Just like #MikeB said, I checked that with XML validators on the web but then realized the problem was that I was using invalid XML tag and XML attributes in .pubxml after using the correct one problem was solved!
Check whether you are using your XML node and attributes correctly!
I've recently encountered this problem in VS 2019 with a project whose .pubxml profiles had been working fine and have not changed for quite a while.
The problem turned out to be a corrupted .pubxml.user file that was preventing VS from loading any profiles. The .pubxml.user files exist in the same directory as the .pubxml file and deleting them solved the issue for me.
I had the same issue. One of the .pubxml has conflict, after resolving the conflict(SVN) it worked.

Can't get past Microsoft.VisualStudio.MinShell.Msi.msi in VS2017 RC Update

I previously successfully installed Visual Studio 2017 RC Enterprise on Windows 10 Home. I saw in the Notifications area an update to a later version of the RC, and so I clicked on that notification to install it.
The installation got as far as the attempting to install the Android Emulators, but failed and the log said it needed Win10 Pro.
So I removed the emulator from the install options, but the install didn't complete and this time the log said:
[27ac:0038][2017-01-31T10:08:47] Download requested: https://download.microsoft.com/download/8/7/A/87AEAAB0-D624-400E-899E-61FAFAE42BA5/Microsoft.VisualStudio.MinShell.Interop.Msi.msi
[27ac:003a][2017-01-31T10:08:47] Attempting download 'https://download.microsoft.com/download/8/7/A/87AEAAB0-D624-400E-899E-61FAFAE42BA5/Microsoft.VisualStudio.MinShell.Interop.Msi.msi' using engine 'WebClient'
[27ac:0026][2017-01-31T10:08:48] Completed: Installing Microsoft.VisualStudio.MinShell.Msi
[27ac:0026][2017-01-31T10:08:48] Error: Package 'Microsoft.VisualStudio.MinShell.Msi,version=15.0.26109.1' failed to install. MSI: C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.VisualStudio.MinShell.Msi,version=15.0.26109.1\Microsoft.VisualStudio.MinShell.Msi.msi, Properties: REBOOT=ReallySuppress ARPSYSTEMCOMPONENT=1 MSIFASTINSTALL="7" VSEXTUI="1" VS7.3643236F_FC70_11D3_A536_0090278A1BB8="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise" , Return code: 1316, Details: The specified account already exists.
I tried to follow the instructions from Visual Studio 2017 RC Install Error "The specified account already exists." however its says the action is only valid for installed products
Yesterday I did notice MinShell in the Programmes Uninstall list and tried removing it from there.
However it makes no difference and every time I try and run the installer I get the same error. I have tried making sure that no VS2017 related items are installed in Programs and Features, and deleting directories manually from Program files etc
Starting to get really annoyed as I had a completely working compiler and IDE and I've already been totally unable to upgrade Win10 to the Anniversary Update due to the 0x8007002C – 0x400D error during Migrate-Data operation. I tried the fix of resetting the Storage app to make all defaults C:, and then the Documents link, but that didn't fix it, although I see I've missed Downloads, Pictures and Video, so will try again tonight but I still don't see it working, although I think the failure moved from 79% to 83%
#Peter Nimmo I had the same issue. Solve it by:
Go to C:\Program Data\Microsoft, go to Properties then click the Security tab and add System, then give full permission. The reason why it couldn't install is because it can't access the folder required.
Hope it works for you. If it doesn't, you could try the following additional steps:
Go to C:\ then at the search box type %temp% then delete everything in it.
Run this script in Powershell Admin mode: https://gist.github.com/heaths/77fbe0b44496960fab25c2eb0b9e8475.
This problem might be caused by setting a separate cache folder when installing. The steps below should fix it.
delete the visualstudio folder in your Registry editor HKEY_LOCAL_MACHINE\SOFTWARE(under Microsoft?)
run InstallCleanup.exe---> C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\layout
delete contents in your temp folder C:\Users\yourusername\AppData\Local\Temp(skip items that cannot be deleted)
run InstallCleanup.exe
inside C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\layout
then restart your computer
Go to %ProgramData%\Microsoft and rename VisualStudio folder (e.g. to VisualStudio_old)
Try again with fresh install.
Please temporarily disable 3rd party anti-virus software and try the following steps to check if it works for you:
Type “Administrative Tools” in search box
Open “Local Security Policy”
Navigate to “Software Restriction Policies” (If it displays “No Software Restrictions Defined”, please right-click on the “Software Restriction Policies” node and select “New Software Restriction Policies”)
Double-click on “Enforcement”
Select “All users except Local Administrators” and click on OK
Restart your computer and run the Visual Studio Installer as administrator to repair the installation
Please Refer : https://learn.microsoft.com/en-us/answers/questions/147767/visual-studio-2019-can39t-install-microsoftvisuals.html
similar error for me sort of, it starts installing then gets stuck on shell(minimum) and shell interops and the shell(minimum) resources and interop resources..then i get a fatal error, tells me that Visual Studio Devenv resource fails.. no matter what i try i cannot install on my windows 10 1607 anniversary update 3 64-bit with all updates to this minute. I read microsoft is aware and its become a huge problem, programming error. Anyone figures out how to install let me know please.
EDIT: so its a huge pain to get visual studio 2015 to install, i kept reinstalling it and everytime the error window came up i read the log, then i manually searched and installed components listed, and also had to manually create folders almost each time following the path listed in the log file. after 12 hours and alot of searching and installing i now have a fully functional visual studio 2015 pro edition back on my computer..i wanted 2017 but thats even worse to install..lol..

How do I fix "Error C1033: cannot open program database"? [duplicate]

During a long compilation with Visual Studio 2005 (version 8.0.50727.762), I sometimes get the following error in several files in some project:
fatal error C1033: cannot open program database 'v:\temp\apprtctest\win32\release\vc80.pdb'
(The file mentioned is either vc80.pdb or vc80.idb in the project's temp dir.)
The next build of the same project succeeds. There is no other Visual Studio open that might access the same files.
This is a serious problem because it makes nightly compilation impossible.
It is possible that an antivirus or a similar program is touching the pdb file on write - an antivirus is the most likely suspect in this scenario. I'm afraid that I can only give you some general pointers, based on my past experience in setting nightly builds in our shop. Some of these may sound trivial, but I'm including them for the sake of completion.
First and foremost: make sure you start up with a clean slate. That is, force-delete the output directory of the build before you start your nightly.
If you have an antivirus, antispyware or other such programs on your nightly machine, consider removing them. If that's not an option, add your obj folder to the exclusion list of the program.
(optional) Consider using tools such as VCBuild or MSBuild as part of your nightly. I think it's better to use MSBuild if you're on a multicore machine. We use IncrediBuild for nightlies and MSBuild for releases, and never encountered the problem you describe.
If nothing else works, you can schedule a watchdog script a few hours after the build starts and check its status; if the build fails, the watchdog should restart it. This is an ugly hack, but it's better than nothing.
We've seen this a lot at my site too. This explanation, from Peter Kaufmann, seems to be the most plausible based on our setup:
When building a solution in Visual Studio 2005, you get errors like fatal error C1033: cannot open program database 'xxx\debug\vc80.pdb'. However, when running the build for a second time, it usually succeeds.
Reason: It's possible that two projects in the solution are writing their outputs to the same directory (e.g. 'xxx\debug'). If the maximum number of parallel project builds setting in Tools - Options, Projects and Solutions - Bild and Run is set to a value greater than 1, this means that two compiler threads could be trying to access the same files simultaneously, resulting in a file sharing conflict.
Solution: Check your project's settings and make sure no two projects are using the same directory for output, target or any kind of intermediate files. Or set the maximum number of parallel project builds setting to 1 for a quick workaround. I experienced this very problem while using the VS project files that came with the CLAPACK library.
UPDATE: There is a chance that Tortoise SVN accesses 'vc80.pdb', even if the file is not under versioning control, which could also result in the error described above (thanks to Liana for reporting this). However, I cannot confirm this, as I couldn't reproduce the problem after making sure different output directories are used for all projects.
Switch the debug info to C7 format instead of using the PDB.
Project Options -> C/C++ -> General -> Debug Information Format and set it to C7.
This generally happens when your previous attempts at debugging have not killed the debugger fully.
In Task manager look for a process called vcjit, kill it and try again.
Worst option restart visual studio, this should solve your problem.
I had this problem today and it turned out to be non-ansi characters in the path to the pdb that caused it.
I'm using windows through vmware, and my project was in a shared location: \vmware-host\Shared Folders\project
When I moved it to \Users\julian\project it resolved the issue.
I just ran into this problem. Visual studio was complaining about not being able to open vc100.pdb. I looked for open file handles to this file using procexp and found out that the process mspdbsrv had an open file handle to it. Killing this process fixed the issue and I was able to compile.
Try right click the excutable file of VS....and Properties->Compatibility-> Tick "Run this program in compatibilty mode for:" OFF........
I had a similar problem while working on a project which I had located in my Dropbox folder. I found that it would throw this error when the little "syncing" icon was going on the Dropbox icon in the system tray, since Dropbox was accessing the files to upload them to their server. When I waited to build until Dropbox finished syncing, it worked every time.
I have same problem C1033: cannot open program database,
Scenario
I have two dll's parent.dll and child.dll.I just attached child.dll project with visual studio debugger at the same time i am trying to build the parent.dll project,produces error C1033: cannot open program database
Solution
Stop debugging and kill the process attached with the debugger.Rebuild the project
This happens to me consistently if I Ctrl+Break to cancel a build (vs2015). There's some process that isn't shut down properly. I went on a rampage "End Tasking" ms/vs related processes (look for duplicates) and my build worked again. A restart would probably work too. As would moving to gnu binutils.
Annoyingly unlocker tools don't report any processes locking the file, windows doesn't let me delete the .pdb but I can rename it. My guess is two processes jump in at the same time during a build.
Are you using LinqToSql at all? Perhaps it is similar to the odd error I will experience occasionally as I asked in this question: What causes Visual Studio to fail to load an assembly incorrectly?
I changed my intermediate directory from:
%TEMP%\$(ProjectName)\$(Platform)\$(Configuration)\
to
C:\temp\$(ProjectName)\$(Platform)\$(Configuration)\
It works now. NO idea why.
In my case the problem was Google Drive: I forgot that the project was under a synced folder and G Drive probably locked that file. Pausing the sync didn't help since the error was throwed anyway.
Moving the project folder to another location not synced by Google Drive solved my issue.
Just to mention, at the beginning I thought it was my anti-virus, since when examinating the file using procexp it showed that the file was used by one of my anti-virus process. Excluding the folder project from my anti-virus scan didn't help in my case.
the simplest solution is "build one more time":
BuildConsole abc.sln /rebuild /cfg="release|Win32"
if %errorlevel% neq 0 (
BuildConsole abc.sln /cfg="release|Win32"
if %errorlevel% neq 0 (
rem process error
exit 1
)
)
I just ran into this problem and Google led me here. For me, it was Google Drive syncing my project files while I'm trying to run. Pausing Google Drive sync temporarily solved it, but I'd rather there was a way for Google Drive to keep its hands off while Visual Studio is doing its stuff. If anyone knows how I can configure that, please let me know

WebStorm: When working with remote files, "Error: Could not save project: null"

I'm having a problem with WebStorm only when working with files that are on a mapped drive. I can work with / save files with no problem, but I do get an error prompt saying Could Not Save Project: null.
This happens if I either work in a director or project on a different drive. I have sufficient rights on that drive. Files save fine, but are followed by the error. I have tried completely creating a project on a remote drive instead of having moved it from local, and still receive the same message.
I am a Mac installation, and the files are on a Windows 2K8 box.
All other editors (textmate, aptana, vs) do not give me any indication that I have problems saving to this drive, so it seems to be localized to WebStorm.
WebStorm is on the latest version.
As CrazyCoder says, its unsupported. I'm having the same problem with PhpStorm and posted this:
http://youtrack.jetbrains.com/issue/WI-10692?projectKey=WI
The response from jetbrains:
Directly opening project from remote/mapped storage is unsupported.
Use "new project from existing files" wizard to create a local copy
and set up auto sync.
Mapped drives are strictly unsupported by WebStorm. Please file an issue with idea.log attached at http://youtrack.jetbrains.net/issues/WI so that this problem can be investigated by WebStorm developers.