mvc3视图无法加载命名空间(视图如何引用dll)

发布于 2024-12-17 11:19:05 字数 677 浏览 1 评论 0原文

我更新了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七婞 2024-12-24 11:19:05

您必须使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文