Quantcast
Viewing latest article 16
Browse Latest Browse All 49

Visual Studio cleared / deleted my ascx.g.cs file when adding a Register declaration in my web part

Having landed on this page, you’ve most likely experienced the joy of VS clearing the contents of your ascx.g.cs file when adding a Register declaration, in the hope you can simply drop in your super whizzy snap bang custom control.

Well, firstly rest assured you have not killed anything.  VS will rebuild the file for you.

In the background VS communicates with SharePoint when you save the ascx file to build that cs file and if there are any issues, it just bums out and builds nothing.  Awesome!

You will probably find that you need to deploy your assembly containing the namespace before you try and use it in your web part.  That way when VS talks to SharePoint, it knows about your namespace.

More info, some comments from MS and lots of user experience/anger can be found here.

http://connect.microsoft.com/VisualStudio/feedback/details/776340/visual-web-part-in-vs2012-code-in-ascx-g-cs-is-erased#tabs

Image may be NSFW.
Clik here to view.

Viewing latest article 16
Browse Latest Browse All 49

Trending Articles