我正在尝试先在Visual Studio Web Express 2012中启用代码。根据我到目前为止所读到的内容,我必须使用Package Manager控制台和Enable-Migrations命令。当我这样做的时候,我得到了以下错误。
Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///E:\Working\wingtoysdl\C#\packages\EntityFramework.5
.0.0\tools\EntityFramework.PowerShell.Utility.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)"
At E:\Working\wingtoysdl\C#\packages\EntityFramework.5.0.0\tools\EntityFramework.psm1:398 char:62
+ $utilityAssembly = [System.Reflection.Assembly]::LoadFrom <<<< ((Join-Path $toolsPath EntityFramework.PowerShell.Utility.dll))
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
You cannot call a method on a null-valued expression.
At E:\Working\wingtoysdl\C#\packages\EntityFramework.5.0.0\tools\EntityFramework.psm1:399 char:50
+ $dispatcher = $utilityAssembly.CreateInstance <<<< (
+ CategoryInfo : InvalidOperation: (CreateInstance:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load file or assembly 'file:///E:\Working\wingtoysdl\C#\packages\EntityF
ramework.5.0.0\tools\EntityFramework.PowerShell.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515
)"
At E:\Working\wingtoysdl\C#\packages\EntityFramework.5.0.0\tools\EntityFramework.psm1:431 char:31
+ $domain.CreateInstanceFrom <<<< (
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException正如你所看到的,这是一个非常大的错误,使得谷歌和故障排除变得非常困难。有没有人知道我该怎么解决这个问题?
发布于 2013-02-21 12:14:01
我已经遇到这个问题两次了。两次我都必须卸载实体框架,然后为解决方案中的每个项目重新安装它。我花了一段时间才弄清楚第二次这样做的原因是,在重新安装实体框架之后,我必须重新启动Visual Studio (2012) (或者我继续得到“had not load file or assembly 'path\packages\EntityFramework.5 .0.0\tools\EntityFramework.PowerShell.Utility.dll'”error“)。
要进入包管理器控制台,请转到:工具->库包管理器->包管理器控制台
在Package Manager中,卸载每个项目的实体框架(我从Package Manager控制台顶部的Default project下拉列表中选择了每个项目):
卸载-打包EntityFramework -Force
然后为每个项目安装它:
安装-Package EntityFramework
此时,尝试运行Enable-Migrations命令仍然显示错误,直到我关闭并重新启动Visual Studio。然后它成功了,就像更新数据库命令一样(在Migrations.Configuration文件中将AutomaticMigrationsEnabled设置为true之后)。
发布于 2014-01-30 16:57:56
在网络驱动器上使用项目时,在两台不同的计算机上有相同的问题。This answer帮我解决了这个问题。
发布于 2014-03-08 06:59:22
这可能是一个延迟的答案,但这似乎是一个权限/访问问题。确保您的项目不是从映射驱动器或类似驱动器打开的。
如果您在公司网络上并登录到域,则很可能您的用户配置文件实际上并不在本地计算机上,而是在服务器上。这将导致相同的问题。
尝试将项目复制到本地c:,然后重试。
https://stackoverflow.com/questions/12318107
复制相似问题