Visual Studio 2012 and Visual Web Parts Bug?

Ben SteginkUncategorized1 Comment

After about 5 hours of irritation and troubleshooting, it appears there is a bug in Visual Studio 2012 when creating visual web parts. I don’t think this is the first visual web part I created with VS2012, so I’m not sure if this is a bug that has always been there or was introduced with an updated. But, here it is:

Open Visual Studio 2012 and create a Visual Web Part. Both VisualWebPart1.ascx and VisualWebPart.ascx.g.cs look fine

Add some code, everything still looks fine

Now here is where the issue is, try to register a new dll, say Telerik Control in your web part. You don’t need to go too far, just put in <%@ Register %>. Click back to your VisualWebPart.ascx.g.cs file. WOAH!!! It’s empty? All the code has been erased and your web part is officially busted…

I’ve submitted a bug to https://connect.microsoft.com/VisualStudio/feedback/details/776340/visual-web-part-in-vs2012-code-in-ascx-g-cs-is-erased, but if anyone can verify I’m not the only one having this issue or any other thoughts I would appreciate it!  If I am the only one, I welcome any ideas as to why this is happening. I’ve done the above on two different SP Servers with identical results in both places.