Web API: CMSDependencies vs NuGet

Yannick - asked on June 1, 2016 10:55

I followed the guidelines at https://docs.kentico.com/display/K82/Using+ASP.NET+Web+API+with+Kentico to build a custom Web API controller. I installed the ASP.NET Web API dependencies through NuGet in a separate class library as instructed but now I get the following error:

"Could not load file or assembly 'System.Web.Http.WebHost, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."

And after refreshing the page:

"Original error: Could not load file or assembly 'System.Web.Http.WebHost, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."

I suspect that there's a version conflict with the dll's that get added in the CMSApp project through the CMSDependencies folder.

  • I don't get how and where these dll's are being referenced and could cause a conflict?
  • Do we really need to use these versions or is there a way to use NuGet packages for all projects in the solution and delete the CMSDependencies folder from source control?

Additional questions:

  • What does the AssemblyDiscoverable attribute do? Does Kentico use it to load the contained types with Reflection?
  • It seems like there's some "magic" causing the CMSApp_AppCode project becoming one with the CMSApp project after building the solution. What is this magic (linked files?) ? CMSApp_AppCode doesn't seem to contain the AssemblyDiscoverable attribute. The weird thing is that when deploying, you still need to copy CMSApp_AppCode over CMSApp.

Recent Answers


Chetan Sharma answered on June 1, 2016 13:56

Hi,

A quick Stackoverflow search will give you a detailed answer. However this is what it means.

  1. The DLL in your bin folder and the DLL referred in your web.config file have a mismatch. You need to update web.config with the version you have in your bin folder for this dll.

If you can resolve this error you should be all set.

Thanks, Chetan

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.