Victor's Blog

Live as if you were to die tomorrow. Learn as if you were to live forever


Troubleshoot warning - "Found conflicts between different versions of the same dependent assembly"

In my last post I said I had issues when Nuget auto updated my nuget packages to the latest version. One of those is that I received a lot of warnings after the compilation - "warning MSB3247: Found conflicts between different versions of the same dependent assembly." But the compile result didn't tell me which dll caused issue and the correct version.  Here is how I fix these:

Change the "MSBuild project build output verbosity" to "Detailed" or above. To do this, follow these steps:

  1. Bring up the Options dialog (Tools -> Options...).
  2. In the left-hand tree, select the Projects and Solutions node, and then select Build and Run. Note: if this node doesn't show up, make sure that the checkbox at the bottom of the dialog Show all settings is checked.
  3. In the tools/options page that appears, set the MSBuild project build output verbosity level to Detailed (assuming you're on VS2010; Normal will suffice in VS2008 or older).

Build the project and look in the output window. You should be able to find message like this
"There was a conflict between "System.Core, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "System.Core, Version=, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes"."

Now you know which dll caused the warning and which version is correct. Update your project reference and recompile your project. The warning message should be removed.

Note: Please do not forget to change your build output verbosity level back to minimal once you fix all your warning.

Enable Nuget Package Restore for your solution could be a bad idea.

Nuget Package Restore in visual studio could be a very handy feature. But sometimes it could cause you more troubles than you think. I recently reorganized the folder structure for one of my MVC4 projects. When I finished that, visual studio restored all packages for me. Then I found out Nuget not only restored installed packages, but also updated them to the latest version automatically which includes from mvc4 to mvc5, entity framework 5 to entity framework 6. It took me more than 2 days to completed fix the build. Just image if this happens when you are in a tight project time frame.......

So I think the best way is to disable Nuget Package Restore in visual studio and check in all your packages to your source repository. Let your CI builds to check any missing packages. 

Weird exception in EF6 unit test

I am using Effort to perform my data access layer unit test. It worked fine until I upgraded my entity framework to version 6. Then I got this wired exception:

"The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application"

I googled this exception. A lot of people thought this was caused by the EF dlls were not deployed at part of the test. But this didn't resolve the issue for me. So I decided to comment out the provider section in app.config for the unit test project and try my luck.

     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />    

Guess what, everything is back to normal agin. Sounds stupid, but it works:D