0

当我右键单击一个文件夹并单击“添加控制器”时,我收到此错误:

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

这是一个完全相同的问题。

无法添加 MVC 控制器 VS2012 给出“对象引用未设置为对象的实例”

解决方案是安装 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.
4

1 回答 1

0

我需要安装 SP 1 才能安装 Powershell .. 虽然我有它:p

于 2013-10-21T11:52:26.867 回答