简体   繁体   English

安装Visual Studio 11 Beta之后InvalidOperationException

[英]InvalidOperationException After installing Visual Studio 11 Beta

I recently installed Visual Studio 11 Beta with .Net Framework 4.5 on mine production machine (but left Visual Studio 2010 side-by-side). 我最近在矿山生产机器上安装了带有.Net Framework 4.5的Visual Studio 11 Beta(但并排放置了Visual Studio 2010)。 It worked fine for me for couple of days, but then it started throwing InvalidOperationException in this section of code: 它对我来说工作了好几天,但是随后在此代码段中InvalidOperationException

ItemDB itemDB = new ItemDB();
ItemDetails item = itemDB.GetItem((int)Session["itemId"]);
string code = item.Code;
Control html = ParseControl(code);
placeholderPage.Controls.Add(html);

Exception happens on line where I ParseControl , in string code I have regular html. 我在ParseControl行中发生异常,在字符串代码中我有常规的html。 The strangest thing is that this code worked perfectly before I installed new Visual Studio, and it still works on colleges machine where he has VS2010 on .NET Framework 4. 最奇怪的是,在我安装新的Visual Studio之前,此代码可以完美地工作,并且仍然可以在他在.NET Framework 4上安装VS2010的大学机器上工作。

After exception it shows me this message: Cannot instantiate type 'TracedLiteralControl' because there is no public parameterless constructor. 出现异常后,它向我显示以下消息: Cannot instantiate type 'TracedLiteralControl' because there is no public parameterless constructor.

I had the same annoying problem, but when using Page.ParseControl. 我有同样烦人的问题,但是使用Page.ParseControl时。 Here are details: System.InvalidOperationException occurred Message: Cannot instantiate type 'TracedLiteralControl' because there is no public parameterless constructor. 这是详细信息:发生System.InvalidOperationException消息:由于没有公共的无参数构造函数,因此无法实例化类型'TracedLiteralControl'。

Then looking at the CallStack I found the following interesting line: Microsoft.VisualStudio.Web.PageInspector.Loader.dll!Microsoft.VisualStudio.Web.Runtime.WebForms.TracedLiteralControlBuilder.BuildObject() + 0x2f bytes 然后查看CallStack,我发现以下有趣的行:Microsoft.VisualStudio.Web.PageInspector.Loader.dll!Microsoft.VisualStudio.Web.Runtime.WebForms.TracedLiteralControlBuilder.BuildObject()+ 0x2f字节

Looks like, for the purpose of new PageInspector feature, VS 11 plugs an assembly in my web app runtime. 出于新的PageInspector功能的目的,VS 11似乎在我的Web应用程序运行时中插入了程序集。 I didn't for sure added that assembly, so the obvious place to look for was in the .NET Framework configuration and in particular in web.config 我不确定是否添加了该程序集,因此寻找的明显地方是.NET Framework配置,尤其是在web.config中

In my case the file is placed under C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Config\\web.config and "Bingo" - on line 88 I found next: 在我的情况下,文件位于C:\\ Windows \\ Microsoft.NET \\ Framework \\ v4.0.30319 \\ Config \\ web.config和“ Bingo”下-在第88行中,我接下来找到:

<add assembly="Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

I commented out the line and my apps are working fine again. 我评论了这一行,我的应用程序再次正常运行。

Hope that helps, Velio 希望有帮助,Velio

If you have problems with the Page Inspector, you can disable it in your own web.config: 如果您在页面检查器方面遇到问题,可以在自己的web.config中将其禁用:

<compilation defaultLanguage="c#" debug="true" targetFramework="4.0">
  <assemblies>
    <remove assembly="Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </assemblies>
</compilation>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 安装Visual Studio 11 beta后,不再通过Visual Studio 2010执行测试 - Tests are no longer executed through Visual Studio 2010 after Visual Studio 11 beta was installed Visual Studio 11 Beta ... WPF模板? - Visual Studio 11 Beta… WPF template? 从资源添加图像 - Visual Studio 11 Beta C# - Adding image from resources - Visual Studio 11 Beta C# 如何在Visual Studio 11 Beta中为接口和委托设置语法突出显示? - How to setup syntax highlighting for interfaces and delegates in Visual Studio 11 Beta? Visual Studio 11 Beta设计器视图无法打开并引发错误 - Visual Studio 11 Beta Designer View does not open and throw an error “@ Model”,“@ Viewbag”和“@Url”“在当前上下文中不存在”使用Visual Studio 11 Beta / Visual Studio 2012 RC时的Razor MVC3 - “@Model”, “@Viewbag” and “@Url” “does not exist in the current context” Razor MVC3 when using Visual Studio 11 Beta/Visual Studio 2012 RC Visual Studio Lightswitch Beta2 - Visual Studio Lightswitch Beta2 Visual Studio中的双工WCF项目InvalidOperationException - Duplex WCF Project In Visual Studio InvalidOperationException 安装 Visual Studio 时出错 - Error installing Visual Studio 安装Visual Studio 2015.1后出现UWP SplitView问题 - UWP SplitView Issue After Installing Visual Studio 2015.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM