I recently installed Visual Studio 11 Beta with .Net Framework 4.5 on mine production machine (but left Visual Studio 2010 side-by-side). It worked fine for me for couple of days, but then it started throwing InvalidOperationException in this section of code:
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. 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.
After exception it shows me this message: Cannot instantiate type 'TracedLiteralControl' because there is no public parameterless constructor.
I had the same annoying problem, but when using Page.ParseControl.
Here are details:
System.InvalidOperationException occurred
Message: Cannot instantiate type ‘TracedLiteralControl’ because there is no public parameterless constructor.
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
Looks like, for the purpose of new PageInspector feature, VS 11 plugs an assembly in my web app runtime. 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
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:
I commented out the line and my apps are working fine again.
Hope that helps,
Velio