mvc3视图无法加载命名空间(视图如何引用dll)
我更新了 mvc3 站点中的 dll 引用。它们是相同的 dll,但版本不同。我通过首先删除它们,然后添加更新的来做到这一点。全部编译正确。但是在运行时,我收到 cshtml 文件无法引用某些名称空间的运行时错误。当我打开这些cshtml文件时,vs2010确实显示未定义名称空间的错误。但相同的命名空间在代码隐藏 cs 文件中工作得很好。在各自查看web.config文件。我已经尝试过:
<namespaces>
...
<add namespace="myassembly" />
</namespaces>
or
<controls>
<add assembly="myassembly, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="myassembly" tagPrefix="myassembly" />
</controls>
我认为仍然无法纠正问题。当我恢复到旧的 dll 版本时,一切正常,我不需要在视图 web.config 中进行修改。看起来视图仍然试图引用旧的 dll 版本,因此当我更新到新版本时它找不到它们。
视图如何引用dll?
谢谢
I updated the dll references in my mvc3 site. they are the same dlls but different versions. I did this by first deleting them, then added the updated ones. All compiles properly. However at runtime, I get runtime errors of cshtml files not being able to reference some namespaces. When I open these cshtml files, the vs2010 does show an error of undefined namespaces. BUT the same namespaces work fine in codebehind cs files. In the respective view web.config file. I have tried:
<namespaces>
...
<add namespace="myassembly" />
</namespaces>
or
<controls>
<add assembly="myassembly, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="myassembly" tagPrefix="myassembly" />
</controls>
I still can't rectify the problem in my view. When I revert to old dlls version, EVERYTHING works fine and I don't need modification in view web.config. It seems like its a case of the view still trying to reference the old dll version, hence it can't find them when I update to new versions.
How do views reference dlls?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用 Views 文件夹中的 web.config 文件,而不是项目根目录中的文件。
You have to use the web.config file that is inside the Views folder, not the one that is in the root directory of your project.