Wednesday, March 19, 2014

It shouldn't be this hard .... (part I)

So I'm ready to start playing with OData and WebAPI to be a backend for my services.

Story version -- it shouldn't be this hard. .NET was supposed to fix the version issues with DLLs - seems like it swapped one set of headaches for another.

Long version:

1) Created new ASP.NET Web Application project in Visual Studio 2013
2) Selected MVC & Web API + test project with no authentication
3) Added to TFS (as it's an internal project; drivers and other code with be on Git)
4) Updated all NuGet Packages (I installed VS about 1 hour before starting this trek) - there were 2 pages listed
5) Imported my Azure Subscriptions
5) Right clicked on Models and selected Add -> ADO.NET Entity Data Model
6) Had to go to my Azure management page to get my DB info, even though I did the import on step 5
7) Entered my Azure SQL DB info.
8) Screen showed that EntityFramework 6 couldn't be selected as my project referenced an older version. No option to install now via NuGet -- only to continue with an older version or cancel and start over. So I cancelled out of the dialog.

NuGet manager is showing that EntityFramework is available for installation. Even though EF5 is installed, NuGet is not showing that.

9) Installed EF6 via NuGet.
10) Start the DB model over again (glad that it remembered my Azure settings)
11) Now there's no longer a selection screen for EF version, just right to selecting my objects - selected all and kept the default options.
12) Compiled the project for the first time and I get this error:

Assembly 'xxxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Http, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

Mind you I didn't nothing in NuGet or anywhere else to select a version for System.Web.Http

13) Went to Add Reference to see if I can find a 5.1 version of System.Web.Http, and there's only 4.0.0.0 listed under extensions.
14) Found there's a version of Microsoft.AspNet.WebApi.WebHost that's version 5.1.1
15) Going back to Package Manager, it shows that I've got that installed already ... hmmm.
16) So I add this to the Web.Config:

<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="5.0.0.0-5.1.1.0" newVersion="5.1.1.0" />
</dependentAssembly>

17) Compile again and same failure. So at this point I've added nothing that wasn't Microsoft generated and it can't compile. All I've added is EF6 via NuGet and built my ADO.NET model.

I'm sure you can sense the increasing frustration ....

18) I tried to PM>  install-package microsoft.aspnet.webapi.webhost -version 5.1.1.0 - and of course it says that it's already installed.
19) Let's re-install all packages: PM> Update-Package -Reinstall

Still won't compile. Really?!?!?

20) The Reference to System.Web.Http is to version 5.1.0.0

21) Back to Web.Config and added the assembly:
  <system.web>
<compilation debug="true" targetFramework="4.5" >
<assemblies>
<add assembly="System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
    <httpRuntime targetFramework="4.5" />
  </system.web>

Guess what ... still won't compile.

Going to walk away from this, as I'm getting nowhere.



No comments:

Post a Comment