Problems with applying multiple SPWebConfigModification objects

Last week I struggled again with (some of the most unpredictable features within the the SharePoint code base:) SPWebConfigModification. I just couldn't apply multiple mods at once. So after few hours of trial and error I discovered that this was the solution:

BAD CODE (will apply only 1 mod):

SPFarm.Local.Services.GetValue().ApplyWebConfigModifications();
webApplication.Update();

GOOD CODE (will apply all mods):

webApplication.Update();
SPFarm.Local.Services.GetValue().ApplyWebConfigModifications();

So the punchline is that the sequence of the method calling does matter!

HOWTO: SharePoint incoming mail without an Exchange server

It seems to be that some companies do not have an Microsoft Exchange server and rely on other mail systems (like Lotus Domino server) for their corporate email. Recently I was asked at such a company if it is possible to have incoming email enabled on SharePoint without an Exchange server. After a day of research I had to conclude: YES, it's possible! It's not that hard either too!

What do you need to do:

  1. Point a MX (mail relay) DNS record to the SharePoint server. For example wss.company.com. This is because all email will have to be delivered to the SharePoint server.
  2. Enable SMTP on your server http://www.itsolutionskb.com/2008/11/installing-and-configuring-windows-server-2008-smtp-server/

  3. Configure incoming email on the SharePoint server with the following settings:
    Incoming email

This should make it work. However when I tried it my drop folder kept getting cleaned (by the timer job) but the mail never appeared in the list. I played around with some settings and found these working:

mailonlist

VMWARE Player to the rescue!

When you get yourself a performance car, you want to use all the brute force. And that's exactly how you feel when getting a new Lenovo W510 laptop. At least I did. Developing SharePoint solution does require a performance machine. I tried to use Hyper V on the machine but the BSODs made me regret that. So I turned back to VirtualBox. After spending a day creating an image I decided that this could not be the intention of having a W510 with all that power. My Windows Server 2008 image just would work properly. As Virtual PC does not support 64 bit it was just not an option, so the only solution left was to try VMWARE Player. So yesterday I installed it and it gave me a smooth ride so far! So, if you want to experience a smooth virtual ride... use VMWARE Player and abandon VirtualBox.

Drivers to install on Lenovo W510 with Windows 2008 R2

Today I struggled installing Windows 2008 R2 on my new Lenovo W510, so for the record; These are the drivers you need:

Installation instructions can be found here: http://blogs.technet.com/b/keithcombs/archive/2010/02/10/install-windows-server-2008-r2-on-a-lenovo-thinkpad-w510.aspx

The only think I didn't get to work is Bluetooth although there is something about it on http://www.tipandtrick.net/2008/how-to-enable-bluetooth-in-windows-server-2008-64bit-standard-edition/

To use my W510 with Win 2008 as desktop replacement I configured it this way:

FEATURES:

  • .NET Framework 3.5.1 features
  • Desktop Experience
  • Wireless LAN Service
  • Windows Biometric Framework

ROLES:

  • Hyper V

Don't forget to:

  • Turn off IE Enhanced Security Configuration and the Shutdown Reason dialog!
  • Enable Wireless Zero Config service
  • Start Audio Service and set startup to Automatic

Authenticate a user to AD or AD LDS with C#

Since the .NET 3.5 framework it's very easy to validate a user to an ADAM or AD LDS user store. The following lines of code is all you need:

var pc = new PrincipalContext(ContextType.ApplicationDirectory, "adserver:50000", "o=org,c=nl", ContextOptions.Negotiate, @"domain\user", "password");
Console.WriteLine("Connected to: {0}", pc.ConnectedServer);
var validUser = pc.ValidateCredentials("userToValidate", "passwordToValidate", ContextOptions.SimpleBind);
Console.WriteLine(validUser);

Note that the useraccount MUST be enabled (msDS-UserAccountDisabled = FALSE) and that userPrincipalName should be CN value. Otherwise the validatecredentials method always will return false.

FormatException: Guid should contain 32 digits with 4 dashes...

While doing some development on SharePoint solution deployment I encountered a strange behaviour. The following code gave me the "FormatException:Guid should contain 32 digits with 4 dashes" error:

SPFarm.Local.Solution["demo.wsp"].DeployedWebApplications;

Strange as I'm not even using a GUID in my code here. So a little breaking down led me to the conclusion that if you call the DeployedWebApplications property on a solution that is globally deployed you get this error.

Building STSDEV projects with Team Build

A few months ago I figured out how to build STSDEV projects with Team Foundation Server. So here is the result step-by-step (only the steps that differ from the default project steps):

<ol>
<li>Adjust the target of the solution to DebugBuild. If you are only building STSDEV projects you can do this at once by changing following lines in TFSBuild.proj file:
<pre name="code"><configurationtobuild include="Debug|Any CPU"></configurationtobuild></configurationtobuild></configurationtobuild></configurationtobuild></configurationtobuild></ configurationtobuild=""></></pre>
to:
<pre name="prettyprint"><configurationtobuild include="DebugBuild|Any CPU"></configurationtobuild></configurationtobuild></configurationtobuild></configurationtobuild></configurationtobuild></ configurationtobuild=""></></pre>
or per solution:
<pre name="code"><solutiontobuild include="$(BuildProjectFolderPath)/../../ExampleSolution.sln"></solutiontobuild></solutiontobuild></solutiontobuild></solutiontobuild></solutiontobuild></ solutiontobuild=""></>
<targets></targets></targets></targets></targets></targets></ targets=""></></targets></targets></ targets=""></></ targets=""></></></>
<properties></properties></properties></properties></properties></properties></ properties=""></>Configuration=DebugBuild;Platform=Any CPU</properties></properties></ properties=""></></ properties=""></></></>
</solutiontobuild></solutiontobuild></ solutiontobuild=""></></ solutiontobuild=""></></></></pre>
</li>
<li>Change the DebugBuild in the Microsoft.SharePoint.targets file and make it like this:
<pre name="code"><target name="DebugBuild"></target></target></target></target></target></ target=""></>
<copy condition="'$(IsDesktopBuild)'=='false'" destinationfolder="$(SolutionDir)bin\debug" sourcefiles="$(OutDir)$(TargetName).dll"></copy></copy></copy></copy></copy></ copy=""></>
...
<copy condition="'$(IsDesktopBuild)'=='false'" destinationfolder="$(OutDir)" sourcefiles="$(SolutionDir)DeploymentFiles\$(PackageName)"></copy></copy></copy></copy></copy></ copy=""></>
</target></target></ target=""></></ target=""></></></></pre>
</li>
<li>Override path to STSDEV for the build on the server (TFSBuild.proj):
<pre name="code"><custompropertiesforbuild></custompropertiesforbuild></custompropertiesforbuild></custompropertiesforbuild></custompropertiesforbuild></custompropertiesforbuild></ custompropertiesforbuild=""></>STSDEV="C:\Software\STSDev v1.3\stsdev.exe"</custompropertiesforbuild></custompropertiesforbuild></ custompropertiesforbuild=""></></ custompropertiesforbuild=""></></></></pre>
</li>
</ol>
Once this is done you can build your STSDEV projects on the TeamBuild server. Have fun!

A few months ago I figured out how to build STSDEV projects with Team Foundation Server. So here is the result step-by-step (only the steps that differ from the default project steps):

Adjust the target of the solution to DebugBuild. If you are only building STSDEV projects you can do this at once by changing following lines in TFSBuild.proj file:

<configurationtobuild include="Debug|Any CPU"></configurationtobuild>

to:

<configurationtobuild include="DebugBuild|Any CPU"></configurationtobuild>

or per solution:

<solutiontobuild include="$(BuildProjectFolderPath)/../../ExampleSolution.sln"></solutiontobuild><targets></targets><properties>Configuration=DebugBuild;Platform=Any CPU</properties></solutiontobuild>

 

Change the DebugBuild in the Microsoft.SharePoint.targets file and make it like this:

<pre name="code" class="xml"><target name="DebugBuild">

<copy condition="'$(IsDesktopBuild)'=='false'" destinationfolder="$(SolutionDir)bin\debug" sourcefiles="$(OutDir)$(TargetName).dll"></copy>

...

<copy condition="'$(IsDesktopBuild)'=='false'" destinationfolder="$(OutDir)" sourcefiles="$(SolutionDir)DeploymentFiles\$(PackageName)"></copy>

</target>

Override path to STSDEV for the build on the server (TFSBuild.proj):

<custompropertiesforbuild>STSDEV="C:\Software\STSDev v1.3\stsdev.exe"</custompropertiesforbuild>

Once this is done you can build your STSDEV projects on the TeamBuild server. Have fun!

"Copy local" on assemblies doesn't work

Working on a project I got the problem that one of the binaries was not compiled to the bin/debug folder. Suddenly it hit me... I had that assembly also in the Global Assembly Cache. So it seems Visual Studio doesn't see the need to copy it to local as it is already available in the GAC.

WorkItem email notification with Team Foundation Server 2008

How to setup email notification on having assigned a Work Item to you?


1. Download and install Team Foundation Power Tool for Visual Studio @  http://www.microsoft.com/downloads/details.aspx?FamilyId=FBD14EEA-781F-45A1-8C46-9F6BA2F68BF0&displaylang=en#filelist

2. Start Visual Studio and open the Alert Editor

3. Add new Alert -> Work Item alert -> A Work Item was assigned to me

4. Change your name in "Send To" to your current email address

5. Collapse Work Items Alerts to ensure saving (workaround to start saving procedure)

6. DONE!

Here we go again!

So, this is my 3rd first post at my own blog. So this means that this is my third attempt to have my own blog. My last blog ran on Blogger and it truly is a nice engine, however... not for a sofware developer. I just want to be in control of everything. And now that I've found the truly amazing Umbraco CMS there is nothing holding me back for a final shot at glory! Enjoy!