Welcome

Sharepoint lead is a place where you can read about interesting topics related to sharepoint, and you can also post comments and suggessions.
Showing posts with label Visual Studio 2012. Show all posts
Showing posts with label Visual Studio 2012. Show all posts

Thursday, November 27, 2014

Visual studio hangs

My visual studio 2012 became really really slow when editing ascx file. In entire of my solution there was only 1 web part and bunch of other cs and other important files. I noticed when I am editing ascx file it was really really slow and unresponsive after every couple of seconds.

I found that when you have some urls that uses //somescript.path.js instead of http:// or https:// to allow browser to auto resolve protocol, that is happening.

After reading this somewhere on web, I changed my code to use Request.Url.Scheme in order to dynamically choose protocol instead of using // in the starting and problem was resolved.

Wednesday, April 23, 2014

ascx.g.cs Empty

Bug:
In Visual Studio 2012, when you are working with a visual web part, your user control's ascx.g.cs file becomes empty. So you get an error "The name ‘InitializeControl’ does not exist in the current context".

Root cause:
This is reported as a bug in visual studio 2012 and it generally happens when your server side mark up is having issues. This ONLY happens when you are editing your ascx file.

Suggested Solution:
You can try following:
Short way:

  • try to undo some of the last changes in ascx file.
  • Create copy of ascx file and revert it from source control. Rename g.cs to g.txt and switch to ascx and hit save. That will generate another g.cs with correct content

Long way:

  • Please check the @Register declarations against the TagPrefix and TagName that you are using.
  •  Try to comment out all controls in ascx and save it. That will generate ascx.g.cs along with content again. Now start un-commenting the controls one by one.
  • In worst cases, after trying lots of things people also switch to new web part and migrate useful code from the problematic web part step by step to resolve the error.