Archive

Author Archive

SharePoint 2010: to RBS or not to RBS

January 30th, 2011 1 comment

… that’s the question.

Joel Olsen recently wrote a blog post about the pros and cons of using Remote Blob Storage (RBS) (formerly know as External Blob Storage – EBS). This post also contains a bunch of links to various resources from Microsoft and other vendors of RBS technology.

The bottom line is, that using RBS can greatly improve performance when working with large documents in SharePoint, while the actual data-size is much lower than storing those documents in the SharePoint content-database.

On the other side RBS is would be the wrong choice, when mostly small documents or listdata is stored in SharePoint, because in this case the overhead of moving the data out of SQL-server and into the filestream is too costly. Back in 2006 Microsoft already published a paper called “To BLOB or Not To BLOB: Large Object Storage in a Database or a Filesystem”, which concludes that files smaller than 256 KB would be best stored in the database, while files larger than 1 MB are most efficiently sored in the filesystem. Everything in between “depends”.

Categories: SharePoint Tags: ,

Restart of application pools revised (Windows 2008)

January 30th, 2011 No comments

Up to Windows 2008 there was a nifty little VB-Script called iisapp.vbs. This allowed to just restart the application pool without having to restart the whole IIS. For one this is much faster and also this doesn’t effect other application pool. Thus you can restart a single application.

But with Windows 2008 this script is no longer provided. But fortunatly there is a new kid in town: appcmd.exe. This tool can be found in c:\windows\system32\inetsrv.

To restart (recylce) an application pool you just call:

c:\Windows\System32\inetsrv\appcmd recycle apppool "SharePoint - 80"
Categories: IIS Tags:

Restart of an application pool instead of IIS

January 23rd, 2011 No comments

Once in a while you have to deploy assemblies for a SharePoint based solution (ok, you also might have other solutions which need Assemblies Smiley, but in my case I just stumbled across a SharePoint based solution). But deploying the assembly to the GAC or the local bin folder does not mean, that SharePoint (or the IIS) automatically pick up this new version of the Assembly.

Usually you’ll issue an iisreset command in order to get IIS to reload all needed assemblies. Unfortunatly this does take some time, until IIS is fully restarted. This is especially true, when more than one application-pool is running within IIS (for e.g. central administration as well as a couple of web-applications).

Actually it would be sufficient just to restart the portal web-application instead of the whole IIS. So this would mean, we only restart the application pool. Actually this is quite easy to do. Using iisapp.vbs this is just a matter of

cscript iisapp.vbs /a "SharePoint - 80" /r

Actually this could also be part of a nant-build script, so that with each build the application pool is being restart.

<?xml version="1.0" encoding="utf-8" ?>
<project name="Solution" default="deploy" xmlns="http://nant.sf.net/schemas/nant.xsd">
  <loadtasks assembly="f:\build-tools\nantcontrib\bin\nant.contrib.tasks.dll"/>
  <target name="build">
    <msbuild project="FirstActivity.csproj"/>
  </target>
  <target name="deploy" depends="build">
    <gac-install >
      <assemblies>
        <include name="bin\Debug\FirstActivity.dll"/>
      </assemblies>
    </gac-install>
    <exec program="cscript" commandline="iisapp.vbs" workingdir="c:\windows\system32" verbose="true">
      <arg value="/a &quot;SharePoint - 80&quot;" />
      <arg value="/r"/>
    </exec>
  </target>
</project>
Categories: IIS Tags:

Exponention in c#

January 17th, 2011 No comments

To compute 10 to the power 2 shouldn’t be any problem

int result = 10 ^ 2;

As if! Visual Studio strongly believes that the result of this computation should be 8. Damn! ^ is a reserved symbol in c# for bitwise exclusive or (XOR). The correct way to computer this would be

int result = Math.Pow(10, 2);
Categories: .Net Tags:

Logging in NHibernat 3.0

January 16th, 2011 No comments

With the release of NHibernate 3.0 the way NHibernate handles logging is changed. Up to 2.1.2 NHibernate used log4net exclusive for logging. The usage of log4net was directly tied into each class of NHibernate.

Now this has been decoupled. NHibernate 3.0 introduces a LoggingProvider. So instead of

private static readonly ILog log = LogManager.GetLogger(typeof (Loader));

a new logger is created using

private static readonly IInternalLogger log = LoggerProvider.LoggerFor(typeof (Loader));

Even though this might not seem like a big deal, there is more to the LoggingProvider. The logging provider currently only supports log4net (well, and a NoLoggingLoggerFactory). In order to determine whether log4net is available for logging, the LoggingProvider looks in the current SearchPath of BaseDirectory of the AppDomain like this:

// look for log4net.dll
string baseDir = AppDomain.CurrentDomain.BaseDirectory;
string relativeSearchPath = AppDomain.CurrentDomain.RelativeSearchPath;
string binPath = relativeSearchPath == null ? baseDir : Path.Combine(baseDir, relativeSearchPath);
var log4NetDllPath = Path.Combine(binPath, "log4net.dll");

What go me started was the fact, the my log4net configuration wasn’t creating any log-output, and I was extremely puzzled on why. I checked my config a dozen times without any error. This was working perfectly fine when working with NHibernate 2.1.2.

After looking at the LoggingProvider and the way logging is initialized it struck me: my log4net assembly is located in the GAC – the the lookup for log4net isn’t detecting my log4net assembly! Changing the properties of the reference to log4net to Copy Local resolved this issue.

Categories: .Net Tags:

Supressing Messages from FXCop

January 8th, 2011 No comments

In a recent project I rellay nailed the code using FXCop. The goal was to eliminate all messages of FXCop.

After a short periode of time I already figure: no way! There are just a couple of cases, where I have to irgnore the messages of FXCop. Luckily there is an easy way to supress the messages of FXCop. Just open the context menu of the message and copy the message as SupresseMessage to the clipboard.

suppress_messages

Next you can insert that at the appropriate position within your code, most likely as a method-attribute.

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes")]

OK, so now your’re good to go. The next run of FXCop should present you a lot less messages.

And if not? Something went wrong. Some little, very well hidden comment in the documentations says:

The ConditionalAttribute is applied to this class, specifying the preprocessing symbol “CODE_ANALYSIS” as the conditional symbol that determines whether the attribute call is included or omitted. If the symbol is defined, the attribute call is included; otherwise, the call is omitted.

OK. So opening up the project properties and adding the symbol CODE_ANALYSIS helped a lot in getting the number of FXCop messages down.

Categories: .Net Tags:

Warmup of Application-Pools

January 3rd, 2011 No comments

Starting with IIS 7.5 (Windows 7, Windows 2008 R2) application pools can be started with the help of an IIS module. This module issues web-requests whenever a new worker-process is being started. This eliminitates the need for additional warmup-scripts.

A more detailed describtion on how to use this module can be found at Using the IIS Application Warm-Up Module.

Categories: IIS, Programming Tags:

XHTML in Mantis 1.3 development trunk

December 30th, 2010 No comments

I just wanted to upgrade my current installation of Mantis to the current 1.3.0 trunk. But this wasn’t as easy as in previous development releases of mantis. Obviously the content-encoding switched to more strict xhtml+xml. In previous versions the HTTP content-type was still text/html, which worked just fine. Using Firefox is no problem, but Internet Explorer doesn’t like the content-type application/xhtml+xml and always tries to download the page instead of displaying the page.

To resolve this problem I added a test prior to sending the content type, to which content type is actually supported by the client. The content-type is set in thehttp_api.php, so the modified function http_content_headers() looks like this:

/**
 * Set content-type headers.
 */
function http_content_headers() {
    if ( !headers_sent() ) {
        if (stristr($_SERVER[HTTP_ACCEPT], "application/xhtml+xml")) {
            header( 'Content-Type: application/xhtml+xml; charset=UTF-8' );
        } else {
            header( 'Content-Type: text/html; charset=UTF-8' );
        }
        // Disallow Internet Explorer from attempting to second guess the Content-Type
        // header as per http://blogs.msdn.com/ie/archive/2008/07/02/ie8-security-part-v-comprehensive-pro
        header( 'X-Content-Type-Options: nosniff' );
    }
}

On another quick side-note: I had some custom HTML to include my own header to mantis, which caused an XML parse error – this was because I didn’t close the img tag for an embedded image.

Categories: Programming Tags: ,

Printer mapping in script

December 27th, 2010 No comments

On a side note, a quick way to add printer mappings in a logon script. Even though logon-scripts seem a little out-dated with the power of group policies … non the less.

OK, to map a printer to a local machine you can leverage the rundll32.

rundll32 printui.dll,PrintUIEntry /in /n \\[server]\[printer_share]
Categories: Windows Tags:

New version of SPDisposeCheck available

December 14th, 2010 No comments

When working with SharePoint objects, the correct usage of dispose is a re-occuring question. To answer all thoses questings you can grab SPDisposeCheck. This tool allows to test your solution for the correct usage of the dispose-pattern.

Yesterday a new version 14.0.4762.1000 was released, which now also offers checks, when a dispose is being called, when it is actually not needed.

Categories: .Net Tags: