asp.net-mvcasp.net-mvc-3assembliesexternal-assemblies

mvc3 razor page don't find Namespace


I read a lot of similar questions out there, but I can't solve my particular problem... In my MVC3 project I use an external library. I can use this library everywhere, but not in my razor views.
So, reading some similar question on SO, I found out that I should register this library into the <system.web><compilation><assemblies> section. Trying to do this, I ended up with a portion of my web.config like this

<compilation debug="true" targetFramework="4.0">
  <assemblies>
    ... <!-- default assembly registration, like System.Web.something -->
    <add assembly="MailBee.Net.dll, Version=7.1.4.348, Culture=neutral, PublicKeyToken=cd85b70fb26f9fc1" />
  </assemblies>
</compilation>

But still don't work... or to be more precise, this broke up all the project at runtime. If I launch the project, it crashes telling me Impossibile to load assembly 'MailBee.Net.dll, Version=7.1.4.348, Culture=neutral, PublicKeyToken=cd85b70fb26f9fc1' or one of its dependency
The dll for sure is in the /bin folder of the web application and, deleting the declaration in the web.config file, I cau use it in all the project but in the views page. Any idea?


Solution

  • I got it! It's not a problem of dependencies, nor a problem of declaring the assembly or the namespace somewhere... it's just that that library, for some reason, is not copied into the bin folder when building the project! Or better, the reason is that the property "Copy local" on the referenced library is set to false, but I have no idea why: every other third party library I tried with haven't this behaviour...