Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSharpAddImportCodeFixProvider encountered an error and has been disabled

Tags:

I had my PC re-imaged for me. I have Visual Studio Version 14.0.25123.00 Update 2 installed on my computer. I'm getting this error when I try to use VS intellisense to reference another project.

CSharpAddImportCodeFixProvider encountered an error and has been disabled

I have two projects. One of them using namespace ProjectName.Web. And the other project using ProjectName.Web.Controllers. The provider crashes when I reference ProjectName.Web.Controllers, I believe because it is setup as a project. Any idea how to fix this?

like image 234
EGN Avatar asked Apr 27 '16 20:04

EGN


2 Answers

I had the same issue on VS-2015 update 3.
I did was :

1) Closing visual studio

2) restarting as administrator

like image 52
Auronmatrix Avatar answered Oct 05 '22 18:10

Auronmatrix


Happened to me when chose Add using System.Data.SqlClient automatically after typing using (SqlConnection...){} in DataLayer, in one of Repository classes.

Nothing helped (except creating new project), but I saw that the problem was with loading System.Data.SqlClient.dll file, although it existed in appropriate folder.

Found by trial and error that after removing Dependencies->Assemblies->System.Data.SqlClient from DataLayer (right click -> Remove, or just press Delete key when selected), I can Add System.Data.SqlClient without any errors.

Didn't try for other cases where CSharpAddImportCodeFixProvider encountered an error and has been disabled message appears, but the solution might be similar.

In my case the problem appeared probably due to .net Core version conflict or something like that, because the project was on external drive and created on another computer.

Edit: Also, some errors might be caused by .vs folder (hidden by default) inside Solution folder, especially if the project is moved between different computers. I know from experience that IntelliSense can seem to be broken and classes from other namespace would be unavailable although using namespace_name statement is present. The solution is to delete .vs folder or just avoid copying it with the project, as suggested here: https://weblog.west-wind.com/posts/2018/Aug/07/Fixing-Visual-Studio-Intellisense-Errors

like image 21
Mladen Janjic Avatar answered Oct 05 '22 20:10

Mladen Janjic