几乎每次我尝试运行用于EF迁移的update-database命令时,我在Visual Studio 2015中都会出现以下错误:
使用“1”参数调用“GetService”的异常:“异常 使用“2”参数调用“Invoke”:“Visual Studio组件 缓存已过期。请重新启动Visual Studio。 Visual Studio 组件缓存已过期。请重新启动Visual Studio。“”在 d:\开发\项目\包\ EntityFramework.6.1.3 \工具\ EntityFramework.psm1:1004 焦炭:5 + $ packageInstallerServices = $ componentModel.GetService([NuGet.Vis ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ + CategoryInfo:NotSpecified:(:) [],MethodInvocationException + FullyQualifiedErrorId:ScriptMethodRuntimeException您无法在空值表达式上调用方法。在 d:\开发\项目\包\ EntityFramework.6.1.3 \工具\ EntityFramework.psm1:1006 焦炭:5 + $ vsPackage = $ packageInstallerServices.GetInstalledPackages()| ? ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ + CategoryInfo:InvalidOperation:(:) [],RuntimeException + FullyQualifiedErrorId:InvokeMethodOnNull Join-Path:无法将参数绑定到参数'Path',因为它为null。在 d:\开发\项目\包\ EntityFramework.6.1.3 \ TOOLS \ EntityFramework.psm1:713 焦炭:28 + $ toolsPath = Join-Path $ installPath工具 + ~~~~~~~~~~~~ + CategoryInfo:InvalidData:(:) [Join-Path],ParameterBindingValidationException + FullyQualifiedErrorId:ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand Join-Path:无法将参数绑定到参数'Path',因为它是 空值。在 d:\开发\项目\包\ EntityFramework.6.1.3 \ TOOLS \ EntityFramework.psm1:780 焦炭:74 + ... [System.Reflection.Assembly] :: LoadFrom((Join-Path $ ToolsPath EntityF ... + ~~~~~~~~~~ + CategoryInfo:InvalidData:(:) [Join-Path],ParameterBindingValidationException + FullyQualifiedErrorId:ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand 您无法在空值表达式上调用方法。在 d:\开发\项目\包\ EntityFramework.6.1.3 \ TOOLS \ EntityFramework.psm1:781 焦炭:5 + $ dispatcher = $ utilityAssembly.CreateInstance( + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:InvalidOperation:(:) [],RuntimeException + FullyQualifiedErrorId:InvokeMethodOnNull Join-Path:无法将参数绑定到参数'Path',因为它为null。在 d:\开发\项目\包\ EntityFramework.6.1.3 \ TOOLS \ EntityFramework.psm1:810 焦炭:20 +(Join-Path $ runner.ToolsPath EntityFramework.PowerShell.dll), + ~~~~~~~~~~~~~~~~~ + CategoryInfo:InvalidData:(:) [Join-Path],ParameterBindingValidationException + FullyQualifiedErrorId:ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
大多数时候重启Visual Studio 2015会解决此问题,但有时我必须通过从C:\ Users {UserName} \ AppData \ Local \ Microsoft \ VisualStudio \ 14.0中删除所有项目来手动清除组件缓存\ ComponentModelCache
我以管理员身份运行VS2015。
答案 0 :(得分:11)
你应该去
%APPDATA%\Local\Microsoft\Visual Studio\<version>
并删除ComponentModelChache目录。