设置:
我使用的是 MVC 3、EF 4.1、Visual Studio 2010 SP1,Power Tools 已更新到最新版本。
通过上述安装,我不需要以前所需的 NuGet 包。一切都是RTM。
该项目已从 MVC 2 升级到 MVC 3。我最初尝试了升级工具,但这让我很伤心,所以我按照 MVC 3 自述文件中的说明手动完成了升级。
问题:
当尝试使用新的控制器和视图基架来实现 CRUD 功能(针对 Code First DbContext)时,基架失败并出现以下错误:
Could not load file or assembly 'file:///C:\[PATH TO MY APP]\bin\Lanap.BotDetect.dll'
or one of its dependencies. Operation is not supported.
(Exception from HRESULT: 0x80131515)
问题:
Lanap.BotDetect 是验证码控件。它工作正常并且存在,我在其他页面中使用它没有问题,解决方案编译等等,所以这个dll没有问题。
然而,这个错误阻止我使用新的脚手架功能。
我看不出它与新控制器及其视图的脚手架有什么关系,所以一定有一些配置是错误的。
关于我可以在哪里查看有什么建议吗?谷歌搜索一片空白。
编辑 1:
我正在尝试按照评论中的建议使用 Fusion Log 查看失败的程序集绑定。没有显示失败的绑定(但这可能是我的错),但问题仍然存在:
为什么 MvcScaffolding 需要加载 Captcha .dll?它只是搭建一个控制器,T4 中没有任何关于这个 .dll 的内容
(注意:我还没有编辑搭建 T4 代码)
编辑 2:
我尝试删除对 Lanap.BotDetect 的引用,并且错误更改为不能够打开具有连接字符串的配置文件(我将连接字符串分流到 db.config 字符串,这样在查看配置文件时可以减少视觉上的痛苦)。
我正在放弃这个应用程序的脚手架。它适用于干净的新应用程序,但不适用于有大量预先存在的代码的应用程序。
Setup:
I am using MVC 3, EF 4.1, Visual Studio 2010 SP1 with Power Tools updated to latest version.
With the above installations, I don't need the NuGet packages that were required previously. Everything is RTM.
The project has been upgraded from MVC 2 to MVC 3. I initially tried the upgrade tool, but that gave me grief, so I did it manually as per the instructions in the MVC 3 Read Me file.
Problem:
When trying to use the new scaffolding of controllers and views for CRUD functionality (against Code First DbContext), the scaffolding fails with the error:
Could not load file or assembly 'file:///C:\[PATH TO MY APP]\bin\Lanap.BotDetect.dll'
or one of its dependencies. Operation is not supported.
(Exception from HRESULT: 0x80131515)
Question:
Lanap.BotDetect is a Captcha control. It works fine and is there, I use it in other pages no problems, the solution compiles, etc, etc. So there is no problem with this dll.
However, this error is stopping me using the new scaffolding capabilities.
I can't see what it has to do with the scaffolding of a new controller and its views, so there must be some configuration that is wrong.
Any suggestions as to where I can look? Googling has drawn a blank.
EDIT 1:
I am trying to see the failed assembly binding using Fusion Log as suggested in a comment. No failed binding showing (but that might be my fault) but the question remains:
Why would MvcScaffolding NEED to load the Captcha .dll at all? It is just scaffolding a controller, and nothing in the T4 says anything about this .dll
(NOTE: I haven't edited the scaffolding T4 code)
EDIT 2:
I tried removing the reference to Lanap.BotDetect, and the error changed to not being able to open the config file that has the connection strings (I shunt the connection strings out to a db.config string, just gives me less visual pain when looking at a config file).
I am giving up on scaffolding on this app. It works in clean, new apps, but not this one where there is a lot of pre existing code.
发布评论
评论(2)
我找到了另一个解决方案。对我来说,问题在于它是通过网络驱动器构建的。因此,当我将项目移动到我的计算机本地位置并重建项目时,它纠正了所有内容。我用屏幕截图详细说明了所有内容,在这里...
http: //ryandunn.co/mvc-having-pains-could-not-load-file-controller-dll
只需检查项目的位置并将其移动到 C: 之后,快速重建让我回来并工作正常。
I found another solution to this. Turns the issue for me was that the issue was it was being built over a network drive. So when I moved the project over to a location local to my machine and rebuilt the project it corrected everything. I detailed everything with screen shots and here...
http://ryandunn.co/mvc-growing-pains-could-not-load-file-controller-dll
Put simply check the location of your project and move it to C: after that a quick rebuild had me back and working normally.
所以我知道您已经继续前进,但我遇到了同样的问题并且刚刚找到了解决方案。事实证明,该错误是由于该程序集不受信任所致,即您从互联网下载了它。
您可以右键单击 .dll 并将其取消阻止来解决问题。有关如何解锁的信息,请参阅以下
http://blogs.msdn.com/b/brada/archive/2009/12/11/visual-studio-project-sample-loading-error- assembly-could-not-be-loaded-和-wi无法从 hresult-0x80131515.aspx 加载文件或程序集或其中一个依赖项操作不支持异常
So I know that you have moved on but I ran into the same problem and just found the solution. It turns out the error is due to the assembly not being trusted i.e. you downloaded it from the internet.
You can right click the .dll and unblock it to fix the problem. For info on how to unblock see the following
http://blogs.msdn.com/b/brada/archive/2009/12/11/visual-studio-project-sample-loading-error-assembly-could-not-be-loaded-and-will-be-ignored-could-not-load-file-or-assembly-or-one-of-its-dependencies-operation-is-not-supported-exception-from-hresult-0x80131515.aspx