Hello guys,
I'm an a problem since 5 days, I'm stuck since 5 days … I check with Julie Lerman (EF guru) and Shawn wildermuth (guru too) they don't find (but thanks for their help it's very kind) but both was sure it's not an EF or .NET Core problem.
I have a simple .NET Core solution, 3 projects, 1 class by project very small very basic
In my WebApî code I have this in the file Startup.cs:
C#public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
services.AddDbContext<StoreContext>(
options => options.UseSqlServer("Data Source=localhost;Initial Catalog=TestingDB;Integrated Security=True;"));
}
An exception is raised on the line where 'AddDbContext' is.
The exception is :
Error CS0012: The type 'DBConenction' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Common, version=4.1.0.0
The same project was working on Julie's box and on Shawn's box. The same project on my 3 boxes (desktop + laptop, laptop for work) same exception.
Then this morning with a lot of courage, I created a virtual box with VMWare pro, I installed Windows 10x64 and install step by step the applications I use. At each steps I tried to run the solution with VS2017
- Install VS2015 and VS2017 Pro (with the latest update : 15.2 (26430.12)) ==> no exception
- SQL Server 2016 standard ===> no exception
- SQL SErver Management Studio 2016 ===> no exception
- Windows update ===> no exception
- Google chrome ===> no exception
6. Add extensions on VS2017 : SuperCharger and CodeRush ===> exception - Uninstall both extensions
- Install Supercharger ===> no exception
9. Install CodeRush ==> exception
10 Disable CodeRush ==> no exception
I think it's clear isn't it ?
This time with all the time lost I don't win a free one year subscription to an "Universal Subscription" or a huge huge huge coupon I won't understand.
I join a .RAR file with the project and a small video.
Could check ?
Christian,
Hi Christian,
Thank you for contacting our support.
I have managed to reproduce this behavior locally. Let me explain that happens.
When the debugger reaches this statement:
services.AddDbContext<StoreContext>( options => options.UseSqlServer("Data Source=localhost;Initial Catalog=TestingDB;Integrated Security=True;"));
Debug Visualizer tries to evaluate the AddDbContext method call expression via the Visual Studio Debugger expression evaluation API and then displays the result.
In this case, the result of the evaluation will be an error message, because the UseSqlServer method is referenced within a lambda expression, and the assembly where it is declared haven't yet loaded at the moment of the program execution.
You can see in this video that the watch window produces the same result for this expression even though the CodeRush extension is disabled: https://www.screencast.com/t/wZGT9JUO2Bi4
So, I recommend you ignore this message because this error doesn't affect the program execution.
Also, we will add a special option for Debug Visualizer which will instruct it to not display compilation errors from the debugger.
I will do more tests but I have some doubt about "this error doesn't affect the program execution"
Hi Christian,
Thank you for the update.
Note that the errors which codes started with the "CS" prefix all are compiler time errors and should not affect the runtime. You could see these errors because the debugger tries to compile the expression on the fly and fails because it has no context of the expression, such as project dependencies and so on. You can see in the screencast above (https://www.screencast.com/t/wZGT9JUO2Bi4) that the Watch window produces the same errors because it utilizes the same evaluation API as Debug Visualizer.
Lost my time (again), marked as "Bug" and no "commercial gesture" not fair.
Christian,
We greatly appreciate your cooperation and the time you spent to prepare such a detailed description of the problem. Thank you.
We have already corrected the behavior you reported and these changes are included in the following daily build: DevExpress.CodeRush.Roslyn-17.1.4.17157.vsix
We hope installing this build will make things better. Please let us know your results once you have an opportunity to try it.
And about the "commercial gesture" ?
Christian,
I cannot comment much on this subject. It is better to contact our management at management@devexpress.com to discuss this kind of questions.