Monthly Archives: September 2012

Changing SharePoint database from SQLExpress Edition to Default SQL Server Instance for Standalone Installation

I’m a big lover of using base machine for SharePoint development work instead of using different VMs. I love that approach,

  1. SharePoint runs much faster as it has more comfortable memory and processing power usage
  2. Visual Studio runs much faster
  3. I have access to all other tools such as MS office etc
  4. Last but no least I will not have to transfer my tools from every time I put up a new VM

I have been running SharePoint 2010 on my desktop for more than a year now, while working few different SharePoint and non-SharePoint projects.  I used this very nice article on how to setup SharePoint on Windows 7 few times now to set my dev env without noticing the SharePoint installation automatically install a SQL Server Express edition instance and make use that as the SharePoint’s database.  This was only noticed when I want to get rid of any redundant processes so that I can free up some of the processing power on the machine. For other .net related development I used to have an full SQL Server installation and addition to that my machine is running an SQL Express Edition instance for SharePoint. So I wanted to get rid of this express edition and make use of full SQL Server edition’s default instance for SharePoint as well.  So started in a hard way, uninstall my SQL express edition instance and ran the SharePoint Configuration Wizard, thinking it will notice the loss of SharePoint Configuration database and ask me to create new farm. But it didn’t go that way, instead wizard keep crashing with the message saying unable connect to SQL Server.

However finally I was able to get it to configure new farm by following steps.

  1. Got the env to disconnect from the farm by setting the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\ServerType to CLEAN_INSTALL and running the SharePoint Configuration Wizard (refer this)
  2. Then set the Server role to be Application (instead SingleServer) by setting registry entry HKLM/Software/Microsoft/Shared Tools/Web Server Extensions/12.0/WSS -> ServerRole key from ‘SingleServer’ to ‘Application’  (refer this)
  3. Then run the ShaerPoint Configration Wizard to configure new farm by providing default sql server instace (or any other SQL Server database instance) as the database
Advertisements

Handle with care, Json Serialization when SharePoint Object Model’s Objects in the code

My team went crazy with the generic error message that they were getting while trying to Serialize an object created of some POCO. One of them even lost good whole day trying to troubleshoot what exactly is the issue.

The serializer is one of the best in business for .Net , the Newtonsoft.Json.JsonConvert.

And the error message they were getting is

“An unhandled exception of type ‘System.StackOverflowException’ occurred in mscorlib.dll”

which hardly express any means of the cause. This error message is thrown when following piece of code is getting executed.

 JsonConvert.SerializeObject(MyEntity, Newtonsoft.Json.Formatting.Indented);

Finally I figured it out that one of the newly added Properties of MyEntity’s class causing the issue.

The newly added Property is of SPUser field.  So the entity class looked like following,

   public class MyEntity

{

public string Name { get; set; }

public string LoginName { get; set; }

public SPUser User { get; set; }

}

So the issue with the Serializer unable to serialize the instance of SPUser. The when I checked the serializer is unable to serialize SPFieldUserValue and SPFieldUserValueCollection as well.

Workaround :

Anyway fortunately I did not want this field necessarily be in the Json that I was getting.

So I decorated each of those fields with [JsonIgnoreAttribute] attribute. Doing that I had to import the Newtonsoft.Json with using directive. That made my entity class look like ,

   public class MyEntity

{

public string Name { get; set; }

public string LoginName { get; set; }

[JsonIgnoreAttribute]

public SPUser User { get; set; }

}

In conclusion, even if you use more improved serializer like Newtonsoft.json, you should be very careful about what you are trying to serialize and desterilize especially when you are dealing with SharePoint Object model’s classes.

Changing SharePoint database from SQL Express edition instance to SQL default instance for Standalone Installation

I’m a big lover of using base machine for SharePoint development work instead of using different VMs. I love that approach,

  1. SharePoint runs much faster as it has more comfortable memory and processing power usage
  2. Visual Studio runs much faster
  3. I have access to all other tools such as MS office etc
  4. Last but no least I will not have to transfer my tools from every time I put up a new VM

I have been running SharePoint 2010 on my desktop for more than a year now, while working few different SharePoint and non-SharePoint projects.  I used this very nice article on how to setup SharePoint on Windows 7 few times now to set my dev env without noticing the SharePoint installation automatically install a SQL Server Express edition instance and make use that as the SharePoint’s database.  This was only noticed when I want to get rid of any redundant processes so that I can free up some of the processing power on the machine. For other .net related development I used to have an full SQL Server installation and addition to that my machine is running an SQL Express Edition instance for SharePoint. So I wanted to get rid of this express edition and make use of full SQL Server edition’s default instance for SharePoint as well.  So started in a hard way, uninstall my SQL express edition instance and ran the SharePoint Configuration Wizard, thinking it will notice the loss of SharePoint Configuration database and ask me to create new farm. But it didn’t go that way, instead wizard keep crashing with the message saying unable connect to SQL Server.

However finally I was able to get it to configure new farm by following steps.

  1. Got the env to disconnect from the farm by setting the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\ServerType to CLEAN_INSTALL and running the SharePoint Configuration Wizard (refer this)
  2. Then set the Server role to be Application (instead SingleServer) by setting registry entry HKLM/Software/Microsoft/Shared Tools/Web Server Extensions/12.0/WSS -> ServerRole key from ‘SingleServer’ to ‘Application’. (refer this)