Search code examples
usingnpgsqlvisual-studio-code

Visual Studio Code: using directive missing or invalid, except it isn't


I started messing with the new Visual Studio Code today and I am running into a small "problem"...of sorts.

I have added reference to Npgsql in the project.json of a Web API project and run 'dnu restore' which also updated the project.lock.json to include the proper references. However the code editor highlights an error for every reference to an Npgsql object, giving me the "are you missing a using directive or reference" message for each one, including the 'using Npgsql;'

The really odd part is that the same tooltip that tells me it doesn't recognize the type..also tells me exactly what it is and does. Intellisense still works and if I execute 'dnx: web'...the whole thing runs just fine with no errors.

I am assuming its just a bug in the new editor but who knows, maybe I've not configured something correctly? Anybody else see this?


Solution

  • You might see this when having two frameworks configured in project.json. By default you will have dnx451 and dnxcore50. It might be that the dependency is only available for one of the frameworks but not for the other. Check the error message VSCode gives you - it will include in []-brackets the framework for which the error is valid.