mvc3 razor 页面找不到命名空间
我在那里读到了很多类似的问题,但我无法解决我的特定问题...... 在我的 MVC3 项目中,我使用外部库。我可以在任何地方使用这个库,但不能在我的剃刀视图中使用。
因此,在阅读有关 SO 的一些类似问题时,我发现我应该将此库注册到
部分。 尝试这样做,我最终得到了像这样的 web.config 的一部分
<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>
,但仍然不起作用......或者更准确地说,这在运行时破坏了所有项目。如果我启动该项目,它会崩溃,告诉我无法加载程序集“MailBee.Net.dll,Version=7.1.4.348,Culture=neutral,PublicKeyToken=cd85b70fb26f9fc1”或其依赖项之一
该 dll 肯定位于 Web 应用程序的 /bin 文件夹中,并且删除了 web.config 文件中的声明,我可以在除视图页面之外的所有项目中使用它。 有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有一些可能的问题:
此外,在位于 Views 目录中的 web.config 文件中,您应该添加一些内容像下面这样:
There are a few possible problems:
Additionally, in your web.config file located in the Views directory you should add something like the following:
我得到了它!
这不是依赖关系的问题,也不是在某处声明程序集或命名空间的问题...只是该库由于某种原因在构建项目时没有复制到 bin 文件夹中!
或者更好的是,原因是引用的库上的属性“复制本地”设置为 false,但我不知道为什么:我尝试过的每个其他第三方库都没有这种行为......
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...