Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC application unable to access path error

I have searched through the forums for an answer but nothing is working and im at a road block. I made a basic MVC application with the default template, added a .mdf database file (basic database with information on students and courses). i added the ADO.NET Entity model with the basic classes for each table in the database. Then i added a controller to just display each item in the database. Now when i run the program for the first time, everything works great and all items are listed. If i close the site and rebuild i got fail to access paths errors, along with fail to delete file errors from certain paths. If i sign out, sign in, delete the obj and bin folder from the projects location, open visual studio community 2017, and rebuild again, it works the first time. Then its the same issues with the same errors. The database was created using visual studio. I figured it was a project thing so i started a new project, deleted all the old files except the .mdf file and no matter which project i use, even a brand new one, it only compiles properly 1 time. I have tried running as admin, following what i can on this site but nothing seems to work and its absolutely frustrating me. Im on an admin account so that cant be the issue. the errors im getting are as follows :

"C:\Users\Austin\source\repos\StudentRegistrationSystem\packages\Microsoft.Net.Compilers.2.1.0\tools\System.Collections.Immutable.dll" to "bin\roslyn\System.Collections.Immutable.dll". Access to the path 'bin\roslyn\System.Collections.Immutable.dll' is denied. StudentRegistrationSystem Error Unable to copy file "C:\Users\Austin\source\repos\StudentRegistrationSystem\packages\Microsoft.Net.Compilers.2.1.0\tools\System.Diagnostics.FileVersionInfo.dll" to "bin\roslyn\System.Diagnostics.FileVersionInfo.dll". Access to the path 'bin\roslyn\System.Diagnostics.FileVersionInfo.dll' is denied. StudentRegistrationSystem Warning Unable to delete file "C:\Users\Austin\source\repos\StudentRegistrationSystem\StudentRegistrationSystem\bin\roslyn\VBCSCompiler.exe". Access to the path 'C:\Users\Austin\source\repos\StudentRegistrationSystem\StudentRegistrationSystem\bin\roslyn\VBCSCompiler.exe' is denied. StudentRegistrationSystem Warning Unable to delete file "C:\Users\Austin\source\repos\StudentRegistrationSystem\StudentRegistrationSystem\bin\roslyn\System.IO.Compression.dll". Access to the path 'C:\Users\Austin\source\repos\StudentRegistrationSystem\StudentRegistrationSystem\bin\roslyn\System.IO.Compression.dll' is denied. StudentRegistrationSystem Warning Unable to delete file "C:\Users\Austin\source\repos\StudentRegistrationSystem\StudentRegistrationSystem\bin\roslyn\Microsoft.DiaSymReader.Native.amd64.dll". Access to the path 'C:\Users\Austin\source\repos\StudentRegistrationSystem\StudentRegistrationSystem\bin\roslyn\Microsoft.DiaSymReader.Native.amd64.dll' is denied. StudentRegistrationSystem Warning Unable to delete file "C:\Users\Austin\source\repos\StudentRegistrationSystem\StudentRegistrationSystem\bin\roslyn\Microsoft.CodeAnalysis.VisualBasic.dll". Access to the path 'C:\Users\Austin\source\repos\StudentRegistrationSystem\StudentRegistrationSystem\bin\roslyn\Microsoft.CodeAnalysis.VisualBasic.dll' is denied. StudentRegistrationSystem Warning Unable to delete file "C:\Users\Austin\source\repos\StudentRegistrationSystem\StudentRegistrationSystem\bin\roslyn\Microsoft.CodeAnalysis.dll". Access to the path 'C:\Users\Austin\source\repos\StudentRegistrationSystem\StudentRegistrationSystem\bin\roslyn\Microsoft.CodeAnalysis.dll' is denied. StudentRegistrationSystem Error Unable to copy file "C:\Users\Austin\source\repos\StudentRegistrationSystem\packages\Microsoft.Net.Compilers.2.1.0\tools\System.ValueTuple.dll" to "bin\roslyn\System.ValueTuple.dll". Access to the path 'bin\roslyn\System.ValueTuple.dll' is denied. StudentRegistrationSystem Warning Unable to delete file "C:\Users\Austin\source\repos\StudentRegistrationSystem\StudentRegistrationSystem\bin\roslyn\Microsoft.CodeAnalysis.CSharp.dll". Access to the path 'C:\Users\Austin\source\repos\StudentRegistrationSystem\StudentRegistrationSystem\bin\roslyn\Microsoft.CodeAnalysis.CSharp.dll' is denied. StudentRegistrationSystem Error Unable to copy file "C:\Users\Austin\source\repos\StudentRegistrationSystem\packages\Microsoft.Net.Compilers.2.1.0\tools\System.Security.Cryptography.Primitives.dll" to "bin\roslyn\System.Security.Cryptography.Primitives.dll". Access to the path 'bin\roslyn\System.Security.Cryptography.Primitives.dll' is denied. StudentRegistrationSystem Error Unable to copy file "C:\Users\Austin\source\repos\StudentRegistrationSystem\packages\Microsoft.Net.Compilers.2.1.0\tools\System.Security.Cryptography.Algorithms.dll" to "bin\roslyn\System.Security.Cryptography.Algorithms.dll". Access to the path 'bin\roslyn\System.Security.Cryptography.Algorithms.dll' is denied. StudentRegistrationSystem Error Unable to copy file "C:\Users\Austin\source\repos\StudentRegistrationSystem\packages\Microsoft.Net.Compilers.2.1.0\tools\System.IO.FileSystem.Primitives.dll" to "bin\roslyn\System.IO.FileSystem.Primitives.dll". Access to the path 'bin\roslyn\System.IO.FileSystem.Primitives.dll' is denied. StudentRegistrationSystem Error Unable to copy file "C:\Users\Austin\source\repos\StudentRegistrationSystem\packages\Microsoft.Net.Compilers.2.1.0\tools\System.Reflection.Metadata.dll" to "bin\roslyn\System.Reflection.Metadata.dll". Access to the path 'bin\roslyn\System.Reflection.Metadata.dll' is denied. StudentRegistrationSystem Error Unable to copy file "C:\Users\Austin\source\repos\StudentRegistrationSystem\packages\Microsoft.Net.Compilers.2.1.0\tools\System.IO.FileSystem.dll" to "bin\roslyn\System.IO.FileSystem.dll". Access to the path 'bin\roslyn\System.IO.FileSystem.dll' is denied. StudentRegistrationSystem

Its hard to explain the problem in its entirety and i will answer any questions anyone has. It is just really frustrating and im unsure of whether its coming down to my version of Visual Studio Community 2017.

I have the most recent visual studio community 2017. The error seems to persist even on a fresh project with a fresh database.

UPDATE Just built a whole new project, whole new sql server database, put a table with 1 entry in it, added the ADO.NET entity model for my test database with one entry, added the controller with the auto generated view to list all items in database, and again worked first time, after rebuild gave me same errors..

like image 485
lionettihua1 Avatar asked Sep 22 '17 02:09

lionettihua1


People also ask

Is ASP.NET MVC discontinued?

However, Microsoft discontinued ASP.NET MVC in 2018. While the framework still works, it isn't being actively developed, and there are no plans to release any new features or updates.

How do we map the error to the view in MVC?

To pass error to the view we can use ModelState. AddModelError method (if the error is Model field specific) or simply ViewBag or ViewData can also be used.


3 Answers

Seems what you are suffering from is a collision of Roslyn versions for your project. You may have installed some dependency (from Nuget perhaps or that came with your project template), that clashes with the version of Roslyn installed for your Project.

If you take a look at the vast amount of errors in your trace above, you would see that your issues stem from the fact that the compiler is struggling to copy Roslyn related libraries. Here is an example:

Unable to copy file "C:\Users\Austin\source\repos\StudentRegistrationSystem\packages\Microsoft.Net.Compilers.2.1.0\tools\System.Security.Cryptography.Algorithms.dll" to "bin\roslyn\System.Security.Cryptography.Algorithms.dll". Access to the path 'bin\roslyn\System.Security.Cryptography.Algorithms.dll' is denied. StudentRegistrationSystem

As far as solutions you have two options:

Option #1: Good old fashion delete key.

Go to your \bin\roslyn folder and delete everything in there; and recompile your project. This will cause Visual Studio to recompute your dependencies and select the correct version of libraries for Roslyn needed for your project and it will put them back for you in your \bin\roslyn folder.

Option #2 Remove Roslyn

Truth is, for your use case, you may not actually need Roslyn for your project, and you can get away with yanking out the dependency... Yes it will work just fine without it. Unless your project is doing some really cool code-analysis stuff, you likely don't need the Roslyn libraries anyway.

For clarity: I am not recommending Option#2, but if you have to you can remove it. Here is a quick blog post by Galdin Raphael that explains how to yank out Roslyn from your project => https://gldraphael.com/blog/removing-roslyn-from-asp-net-4-5-2-project-template/ .

like image 113
Awah Teh Avatar answered Oct 16 '22 10:10

Awah Teh


"I have encountered similar error messages and temporarily resolved the issue by killing the VBCSCompiler.exe process in Task Manager."

Same as I, just need to kill the service, it happend when something got wrong in compilation time and the compiler crash.

like image 30
elSilveira Avatar answered Oct 16 '22 10:10

elSilveira


I have encountered similar error messages and temporarily resolved the issue by killing the VBCSCompiler.exe process in Task Manager.

like image 2
StuartQ Avatar answered Oct 16 '22 11:10

StuartQ