简体   繁体   中英

Error while trying to run project: Access is denied

Trying to Start a Winform solution With Debugging in Visual Studio 2017 causes this error:

Error while trying to run project: Access is denied.

在此处输入图像描述

Running Without Debugging works and starts the project without the error.

在此处输入图像描述

This guy reported the same issue with a WPF project to Microsoft Developer Community (beta testing) but there is no solution: https://developercommunity.visualstudio.com/content/problem/39737/error-while-trying-to-run-project-unable-to-start-3.html

A ProcessMonitor Trace reveals its an Access Denied in the Registry:

39:45.7
devenv.exe
RegCreateKey    \REGISTRY\A\{3883977B-E889-4804-9494-B5A8BC8E3F1D}\Software\Microsoft\VisualStudio\15.0_8708a912\DialogPage
ACCESS DENIED
Desired Access: Maximum Allowed

Since its an Application Hive Registry Key it cannot be changed in RegEdit. UPDATE: You can change this, see my updated answer.

How can I debug projects?

Note: Answering my own question to help others in the future.

Right click on the Winform or WPF Project > Properties > Debug tab > tick Enable native code debugging.

在此处输入图像描述

UPDATE: Use this answer to fix the Registry A Hive in VS2017 (it has its own registry):

https://stackoverflow.com/a/45579640/495455

I had this extremely annoying problem for a couple weeks and I would keep rebuilding my project and copying over the vb code and design code to do a crappy work around.

Today I finally found the root cause of my problem!!!!!

I have a resource folder with images including some of my icon images

In my forms i reference these images from my resource folder

In some rare cases instead of referencing my project resource file i would import from local and select the same image from my local drive with THE SAME NAME .

Apparently it confused the builder and i was able to get my project back operational by deleting the .ico image that was under each form on the solution explorer tree that had imported image files from local and referencing the images from my resource folder​ instead

删除您最近在项目文件中添加的项目。然后运行程序

Try changing the Application Type in project properties to Console Application. When the application type is Windows Forms app, your antivirus might think you are trying to run a malicious content.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM