0

创建一个MVC控制器当我用鼠标右键单击文件夹,然后单击“添加控制器”我得到这个错误:错误试图在VS 2012

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. 

值得一提的另一件事,是,这个错误只accures在一个特定的项目,如果我创建一个新的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

确保这发生在您的特定项目或所有项目上。你的VS 2012安装是否正确?这可能是由于安装不当造成的。 – serene

回答

0

我需要的,以便安装PowerShell安装SP 1 .. thourght我有它时使用错误accours:对