当我右键单击文件夹并单击“添加控制器”时,我收到此错误:
Object reference not set to an instance of an object
当我打开项目时,此错误也开始出现在软件包管理器控制台中。
New-Object : Could not load file or assembly 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
At C:\Users\b\Desktop\Git\EyeglassShop\packages\MvcScaffolding.1.0.9\tools\registerWithMvcTooling.ps1:163 char:27
+ $newProvider = New-Object <<<< $powerShellScaffolderProviderType($mvcScaffoldingProvider)
+ CategoryInfo : NotSpecified: (:) [New-Object], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.NewObjectCommand
这个问题完全相同。
Cannot add a MVC controller VS2012 gives "object reference not set to an instance of an object"
解决方案是安装PowerShell 3,但是当我运行安装程序时,我收到另一个错误:
The update is not applicable to your computer.
另一件值得一提的是,这个错误仅在特定项目中有效,如果我创建一个新的MVC项目,它可以正常工作。
如果我能避免将所有事情都转移到一个新项目上,那我就不会很棒。有什么建议吗?更新
尝试从程序包管理器控制台安装MvcScaffolding时出现错误
PM> install-package MvcScaffolding
Attempting to resolve dependency 'T4Scaffolding'.
Attempting to resolve dependency 'T4Scaffolding.Core'.
Attempting to resolve dependency 'EntityFramework'.
Successfully installed 'T4Scaffolding.Core 1.0.0'.
Successfully installed 'T4Scaffolding 1.0.8'.
Successfully installed 'MvcScaffolding 1.0.9'.
New-Object : Could not load file or assembly 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
At C:\Users\b\Desktop\EyeglassShop\EyeglassShop\packages\MvcScaffolding.1.0.9\tools\registerWithMvcTooling.ps1:163 char:27
+ $newProvider = New-Object <<<< $powerShellScaffolderProviderType($mvcScaffoldingProvider)
+ CategoryInfo : NotSpecified: (:) [New-Object], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.NewObjectCommand
Successfully added 'T4Scaffolding.Core 1.0.0' to EyeglassShop.
Successfully added 'T4Scaffolding 1.0.8' to EyeglassShop.
Successfully added 'MvcScaffolding 1.0.9' to EyeglassShop.
答案 0 :(得分:0)
我需要安装SP 1才能安装Powershell .. thourght我有它:p