Jan 8, 2009

Different versions of the same assembly

I've been getting the Conflicts between different versions of the same dependent assembly compiler warning for a while and finally decided to track it down. The first problem is the compiler gives me no additional information about which assembly is causing the problem. The second problem is the automated fix that Micrsosoft proposes does absolutely no good. I checked and double-checked all of my .dlls, I removed all the references from all the projects in the solution and replaced them. No luck. I downloaded Red Gate's Net Reflector along with the assembly dependency graphing add-in. While they were worthwhile downloads it didn't help. It probably would have, but I didn't have enough information to properly use the tool. The key to solving this issue was contained within the Visual Studio IDE preferences. It turns out you can ask the IDE to actually give you meaningful information when it compiles. Who knew? By default  the IDE is set to Minimal, a better term might have been laconic 
You can change this setting this under the Tools->Options menu item. Scroll down to the Projects and Solutions and click on the Build and Run setting. In the resulting right-hand pane use the bottom pop-up and change the output verbosity to Detailed as shown in the Figure at the left. 
Now rebuild your solution, click on the Output window (use the View->Output menu item if you don't have it showing) and you will have all the data needed to solve the problem. I just grabbed all the data in the window and threw it into my favorite text editor and searched for conflict. I quickly found the following line
There was a conflict between "System.Data.SqlServerCe, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91" and "System.Data.SqlServerCe, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91
Now that I can do something about. All along I was assuming it was one of my .dlls and it turns out it's one of Microsoft's. This explains why the assembly dependency graph didn't help me, I hadn't added this .dll to the diagram. The fix was simple, I just removed the reference to this .dll and re-added it, no more warning and now the correct version of the assembly is getting used.

About Me

My photo
Tod Gentille (@todgentille) is now a Curriculum Director for Pluralsight. He's been programming professionally since well before you were born and was a software consultant for most of his career. He's also a father, husband, drummer, and windsurfer. He wants to be a guitar player but he just hasn't got the chops for it.