Shashwat Chandra – Refresh 2012

Shashwat Chandra – Refres…

[Finding] Unit Test 64 bit Assembly using Visual Studio 2010 RC & Moles Framework


I am a fan of Moles framework when it comes to Unit Tests.

After few discussion threads with Moles Team at [1], came to the conclusion that Mocking Classes with Mole Framework is not supported for 64-bit assemblies.Waiting for their next version now.


LiveJournal Tags: ,

SharePoint 2007 to SharePoint 2010 (Beta & RC) In-Place Migration

SP 2007 to SP 2010 Beta In-Place Migration

Run the SP 2010 Beta executable


Click on Install the software pre-requisite.


Click Next.




Error: An older version of Power Shell was installed on the Server.

Resolution: Remove Power Shell from Windows features and again run the pre-requisite.


Remove Power Shell.




All Pre-requisite installed successfully.




This screen only appears in case of upgrading.






Note (my observation): If you are selecting the 2nd option for preserving the look and feel then your content databases are also upgraded but if you are selecting the 1st option for changing existing SharePoint sites then content databases for existing sites need to be upgraded manually.




Error: Host file missing.

Resolution: Navigate to the ETC directory and copy and paste one of the file. Rename that copied file to hosts. Open the file in notepad and save it after deleting all its contents.



Upgrade Timer Job Run In Progress.



Upgrade timer job successful.

SP 2010 Beta to SP 2010 RC In-Place Migration

This migration might contain bugs. There are patches release for RC version too. Install Prerequisite and SharePoint Server.




Error: There is a compatibility range mismatch between the Web server and database "", and connections to the data have been blocked to due to this incompatibility. This can happen when a content database has not been upgraded to be within the compatibility range of the Web server, or if the database has been upgraded to a higher level than the web server. The Web server and the database must be upgraded to the same version and build level to return to compatibility range.

Resolution: Unknown till now. I guess the error was because when I successfully upgraded from SP 2007 to 2010 Beta, I was seeing my old site content database’s not been upgraded. Without upgrading those I continued migrating from SP 2010 Beta to SP 2010 RC.

SharePoint 2007 to SharePoint 2010 RC In-Place Migration

Works well :)

More Error while upgrade

User Profile upgrade error

OWSTIMER] [UserProfileSharedResourceProvider12Sequence] [ERROR] [11/20/2009 1:43:04 PM]: Action of Microsoft.Office.Server.Upgrade.UserProfileSharedResourceProvider12Sequence failed.

[OWSTIMER] [UserProfileSharedResourceProvider12Sequence] [ERROR] [11/20/2009 1:43:04 PM]: Inner Exception: There are no online service instances for this application.

[OWSTIMER] [UserProfileSharedResourceProvider12Sequence] [ERROR] [11/20/2009 1:43:04 PM]: at Microsoft.SharePoint.SPConnectedServiceApplication.get_ApplicationAddresses() at Microsoft.SharePoint.SPServiceLoadBalancer.<get_EndpointAddresses>d__0.MoveNext() at Microsoft.SharePoint.SPRoundRobinServiceLoadBalancer.GetEndpoints(IEnumerable`1 applicationAddresses) at Microsoft.SharePoint.SPRoundRobinServiceLoadBalancer.BeginOperation() at Microsoft.Office.Server.UserProfiles.MossClientBase`1.get_Channel() at Microsoft.Office.Server.UserProfiles.MossClientBase`1.ExecuteOnChannel(String operationName, CodeBlock codeBlock) at Microsoft.Office.Server.UserProfiles.ProfilePropertyServiceClient.ExecuteOnChannel(String operationName, CodeBlock codeBlock)

[OWSTIMER] [UserProfileSharedResourceProvider12Sequence] [ERROR] [11/20/2009 1:43:04 PM]: Exception: There are no online service instances for this application.

[OWSTIMER] [UserProfileSharedResourceProvider12Sequence] [ERROR] [11/20/2009 1:43:04 PM]: at Microsoft.Office.Server.UserProfiles.ProfilePropertyServiceClient.ExecuteOnChannel(String operationName, CodeBlock codeBlock) at Microsoft.Office.Server.UserProfiles.ProfilePropertyServiceClient.GetProfileProperties() at Microsoft.Office.Server.Administration.UserProfileApplicationProxy.RefreshProperties(Guid applicationID) at Microsoft.Office.Server.Utilities.SPAsyncCache`2.GetValueNow(K key) at Microsoft.Office.Server.Utilities.SPAsyncCache`2.GetValue(K key, Boolean asynchronous) at Microsoft.Office.Server.Administration.UserProfileApplicationProxy.InitializePropertyCache() at Microsoft.Office.Server.Administration.UserProfileApplicationProxy.Provision() at Microsoft.Office.Server.Upgrade.ExtractUserProfileApplication.Upgrade() at Microsoft.SharePoint.Upgrade.SPActionSequence.Upgrade()

Resolution: Delete SSP and then upgrade as told in below technet article. Works like charm.

How to – Deploy RESX to the Web Application App_GlobalResources directory?

I was trying automating the deployment of Resources files to the web application App_GlobalResources directory. Below are some approaches I looked at.The 2nd approach is the proven solution.


1)      Copying Resources files using feature stapling:

In the Feature Activation/Deactivation, we use IO operation to copy resources ( from resources present in the 12 hive feature folder to the App_GlobalResources of Web App Directory)

Drawback with this approach is that it doesn’t copy the resx to all front end servers. Just on the server where it’s getting activated.


2)      Copying Resources files using SharePoint Timer Job:

Here the same operation as explained in [1] is done in the Timer Job Execute method rather than inside feature activation/deactivation.

Advantage of this approach is that timer job runs on every front end thereby overcoming the drawback of [1].

Drawback is adding extra complexity to your product by adding a timer job.


3)      Using SPWebService.ApplyApplicationContentToLocalServer Method

Application resources are located in 12 hive CONFIG\Resources folder. For a web application to use those resources, they have to be copied to their App_GlobalResources folder. The approach is to copy the resources to 12/CONFIG/RESOURCES during wsp deployment. And then use the SPWebService.ApplyApplicationContentToLocalServer() in the feature activation to push the resources from CONFIG\Resources folder to App_GlobalResources. You can do this manually or use the STSADM command: copyappbincontent.

Drawback with this approach is that the resources are copied on all the front end servers.Also with this approach is the resources are pushed to all the web app virtual directory. Also there is no way to delete the resources from the web app virtual directory.


SPWebConfigModification – Is it a mess or a gift?

I generally avoid using this class but one day i don’t have any alternative left with me.
My requirment was to have multiple features activation code to apply web config modifications.There are numerous articles asking you to use ApplyWebConfigModification method once but none tell why? In the quest of answering i digg into this API more which lead me to state this API as mess.

The ApplyWebConfigModification method invokes a SP Timer Job by name ‘SPWebConfigJobDefinition’.This Jobs due to many reason sometimes throw exceptions and can be veiwed in the Event Veiwer Logs.If your web config modifications are not getting applied then you need to check whether you are getting the exceptions in any of the Front End servers.Also you need to check whether any instances of this job are still pending to execute.If there are multiple use of ApplyWebConfigModification then the Job fails to apply changes to web config.However every Job has diffrent instance ids but i have seen cases where if one job fails others also fails.

Finally i end up using one feature activation code using SPWebConfigModifications and other features using manual changes but i am still waiting for Microsoft to make this API  bug-less so that I can mention it as a Gift.

Below are some good articles mentioning common issue you face when you use this class.

SPUtility.SendEmail vs. SmtpClient.Send

When there is requirement  to send email in SharePoint , developers usually use


                          Microsoft.SharePoint.Utilities.SPUtility.SendEmail(web, false, false, emailId, MailSubject, htmlBody);


due to the fact that this class automatically uses the default SMTP configuration settings of the SharePoint.


Developers avoid using System.Net.Mail.SmtpClient class to send emails because they need to have the SMTP configuration before using this class. However they can use the below code snippet to automatically detect the SMTP settings with the help of SPWebApplication.


                            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();

                            message.IsBodyHtml = true;

                            message.Body = html;

                            message.From = new System.Net.Mail.MailAddress(SPContext.Current.Site.WebApplication.OutboundMailSenderAddress);

                            SPOutboundMailServiceInstance smtpServer = SPContext.Current.Site.WebApplication.OutboundMailServiceInstance;

                            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(smtpServer.Server.Address);


                            message.Subject = "Test";




A major drawback of using SPUtility.SendEmail is of its character limitation of 2048 per line which strips out the content of the Email after sending while System.Net.Mail.SmtpClient does not have  any such limitation.

Useful RegEx Patterns

Here is the list of Daily useful regex patterns.







Allows word characters [A-Za-z0-9_], single quote, dash and period must be at least two characters long and less then 128





The password must be longer and contains at least one uppercase, one lowercase, one numeric, and one symbolic character.





Allows alphabetical chars, single quote, dash and space must be at least two characters long and caps out at 128

Name, City Name



Shashwat Chandra,

Shashwat K Chandra,

Shashwat k’ Chandra


\d{1,3}.?\d{0,3}\s[a-zA-Z]{2,30}(\s[a-zA-Z]{ 2,15})?([#\.0-9a-zA-Z]*)?

A Series of digits (Potentially containing punctuation), followed by the series of characters representing the street name and then potentially a type of street and unit number 


45-50!!! South Lake Road

123 Main St., 

2nd Ave Bell Street,

 45-50 South Lake Road #8



Allows 5 digit, 5+4 digit and 9 digit zip codes. Must be at least two characters long and caps out at 128(database size).

Zip Code



^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[-.]?\d{3}[- .]?\d{4}$

Allows phone number of the format: NPA = [2-9][0-8][0-9] Nxx = [2-9][0-9][0-9] Station = [0-9][0-9][0-9][0-9]

US Phone Number


1-617-555-1212, (617) 555-1212


Optional dashes between group of numbers

Credit Card Number, Visa, and Passport Number etc




Allows SSN’s of the format 123-456-7890. Accepts hyphen delimited SSN’s or plain numeric values.



123-45-6789, 987654321


Allows common email address that can start with a alphanumeric char and contain word, dash and period characters followed by a domain name meeting the same criteria followed by a alpha suffix between 2 and 9 character lone

Email Address



Allows HTTP and FTP URL’s, domain name must start with alphanumeric and can contain a port number followed by a path containing a standard path character and ending in common file suffixies found in URL’s and accounting for potential CGI GET data




Allows four octets of numbers that contain values between 4 numbers in the IP address to 0-255 and are separated by periods.

IP Address



Allows one or more alphabetical characters. This is a more generic validation function.





Allows one or more alphabetical and/or numeric characters. This is a more generic regex patterns.





Allows one or more positive or negative, integer or decimal numbers. This is a more generic regex pattern.




Create your own Tabbloid

One way is to help people create more materials that are “print worthy”. Tabbloid from HP is one such project. Tabbloid promises to create a personal magazine out of all your favorite feeds and then deliver it to you as a neat PDF – something that is print-worthy. If a small percentage of people who receive these personal magazines print them, HP would be happy.
~ShashLight bulb

.NET Source Code Available for Debugging

The source code for several key .NET libraries is now available for debugging purposes. They are not "open source" in the sense you can do anything you want with them, instead there is a strict "look but don’t touch" license known as the Microsoft Reference License. Even still, they should be an immense resource to .NET developers.

Scott Guthrie announced that Microsoft intended to release the .NET source code back in October. Since then we have not heard much with everyone’s attention split between Visual Studio 2008 and the various post-release libraries still under development.

The source code is only available via Visual Studio 2008’s integrated debugging features, and then only for the paid SKUs. Hobbyists using VS Express or a third-party editor will not be able to download the files.

Once you follow the instructions in Shawn Burke’s Blog, stepping through Microsoft’s source code is just as easy as looking at you own. You can also look at the source code directly for classes you have already seen, but this requires digging through the symbol cache.

The namespaces included in the initial release are

  • System
  • System.CodeDom
  • System.Collections
  • System.ComponentModel
  • System.Data
  • System.Diagnostics
  • System.Drawing
  • System.Globalization
  • System.IO
  • System.Net
  • System.Reflection
  • System.Runtime
  • System.Security
  • System.Text
  • System.Threading
  • System.Web
  • System.Web.Extensions
  • System.Windows
  • System.Windows.Forms
  • System.Xml

10 types of techies…

10 types of techies… and how to manage them


It’s wrong to stereotype people. It isn’t wrong, however, to recognize classifications of the team members you deal with every day. Many of the types of techies identified below may seem familiar to veteran IT managers. My ideas on how to work effectively with each type follow the descriptions.

This information originally appeared in the article “Tame these 10 types of techies,” by Patrick Andrews.

#1: Human Bottleneck

These techies either demand to do all the coding, or never finish their work, or both. Impress upon them that quality is often the opposite of perfectionism. Also, feed them small, well-defined tasks and praise any competent output that is on schedule.

#2: Bright Green

These straight-out-of-college developers like the new, cool technology. They tend to over-engineer by exploiting all the bells and whistles of the development environment — even when it’s inappropriate. These green techies often rely on their planet-size intellects to help them get back on schedule in predelivery all-nighters. Introduce them to colleagues who recently were Bright Green but learned the hard way to focus on deliverables.

#3: Tried-But-Untested

The mantra of these techies is, “Hey, we’ve got a whole testing team, why should I worry about checking my code?” It’s a guarantee that these specimens will cause you grief, so it’s essential to pull them up short. You’ll be doing them a favor in the long term.

#4: Techno-Babbler

Their code doesn’t work because they “need” something. These techies spend too much time in newsgroups and fail to realize that overusing jargon is not a sign of adulthood. Require these techies to give an acronym-free, from-first-principles explanation of project results to management.

#5: User-Loser

These techies consider many client questions stupid and deem the client worthy of a verbal flame. This often leads to the client not doing business with your company in the future. If your developers have contempt for “suits,” try introducing a “dress-up Wednesday” — and keep them away from outside phone contact.

#6: Task Farmer

As your self-appointed deputy, this type of techie assumes that the project plan is only a guideline and that it’s acceptable for team members to swap roles and tasks without asking you. Clarify that although their suggestions are welcome, you’re the one who carries the weight of the project.

#7: Under the Radar

This colleague has a tendency to generate maximally obscure code. This is usually a way to hide inelegance of implementation and to secure employment by preventing any other developers from working on his or her input. A curative strategy is to make the techie responsible for technical mentoring of a demanding Bright Green team member.

#8: Winging-It Commander

This type of techie’s curriculum vitae says they’re proficient in Java, SQL, and Perl, but their lines of code are sparse and curiously primitive. This techie will also place unusual demands on other team members to help “debug” their deliverables. Projects can’t accommodate this level of on-the-job training. Encourage team members to be honest about their technical comfort zones by offering them appropriate training opportunities.

#9: Prima Donna

These characters simply won’t tackle mundane tasks. And if you suggest that they have to adapt existing code, there’s always a performance of operatic proportions. Make it clear that they’ll work for the technical author for a month if this nonsense persists.

#10: Gender Agenda

Some developers have trouble working for, or even alongside, colleagues of the opposite sex. Challenge their assumptions by introducing them to a cross-section of your most accomplished colleagues.

Project managers don’t have time to conduct therapy sessions in the course of an already-demanding project. All you can do is recognize team members’ specific ongoing issues and ensure that they don’t damage the work in progress.


Get every new post delivered to your Inbox.