Sharepoint lead is a place where you can read about interesting topics related to sharepoint, and you can also post comments and suggessions.

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.

g.cs - How it works!

I recently found during my deployment that once of my visual web part's ascx content is not updated in the staging environment when I deploy wsp!

So, I started searching for my ascx file in 14 hive but did not find it anywhere. That became really frustrating when I was not able to find ascx file in my local farm's 14 hive as well! I did some google searching for g.cs and most of the results were either complaining about "can not find Initialize control" or they got a blank g.cs file!

Then I went ahead and looked into the source code for the g.cs file and I found that for each of your control in ascx, its actually generating elements. For static content, its concatenating to string variable and for all server controls, its generating code and setting properties. I recall doing same in classic web parts without ascx controls and my question was answered.

So, g.cs file is c# version of your ascx code so that it doesn't have to deploy ascx control in file system but instead works just like a classic web part!

Well, in that case, it should work as sandbox solution as well, right? I did not tried it but ideally yes if your code is following limitations for sandbox solutions.

Now the original problem was:
In our organization we use source control system. Upon pull, I got conflicts and I correctly merged ascx file but not properly merged g.cs file considering its useless and visual studio automatically handles it when I will open project.

But that wasn't true. After doing this, when I publish/deploy my wsp, visual studio will not regenerate that file again on build/publish/deploy. It only generates g.cs file again when you hit save in ascx control. That was the answer of my problem.

So, never ignore ascx.g.cs files in your solution, always make sure you merge g.cs files OR after every conflict you hit save in your ascx to regenerate ascx.g.cs file again! That's what I conclude.

I hope this will be helpful to you all!

iCal - Cancel 1 meeting from recurring meetings

I was working on generating an iCAL invite from a calendar item and was having difficulty deleting once of the event from series.

I found that you have to generate the same ICAL invite that you did for recurring event but there will be two things different
  1. Add Recurrence-ID;Value:DATE=yyyyMMDD (your get the value from SPListItem["ReucurrenceID"])
  2. Change the METHOD in your email and ical content to CANCEL
  3. Increment sequence parameter
Once you adjust your cancel invite with these three changes, your email will show remove from calendar link and clicking on it will only remove the event specified in Recurrence-ID.