Feeds:
Posts
Comments

Archive for the ‘Tips’ Category

Sometimes it is a lot handier to just update one of the dll’s in the GAC rather than go through the pain of deploying an entire SharePoint solution. In fact it’s one of the key features that makes the CKSDEV Visual Studio plugin so valuable. Not best practice, to copy directly to the GAC, but very handy in a dev environment.

.NET 4.0 has a new gac location

Today, I wanted to quickly update a dll from a custom SharePoint solution. I was baffled when I could not find the dll in the assembly ( “c:\windows\assembly ” ) folder.

Turns out that starting from .NET 4.0 and up there is a new ‘GAC’ folder in town. It is now located in “c:\windows\microsoft.net\assembly“. You can simply browse to that directory with Windows Explorer and view all the folders.  The new GAC folder does not hide version information (=folders) anymore like the old one did.

assembly

They introduced this new folder to avoid issues between CLR 2.0 and CLR 4.0 , the GAC is now split into private GAC’s for each runtime.  The main change is that CLR v2.0 applications now cannot see CLR v4.0 assemblies in the GAC.

So keep in mind there are two folder now. One for .NET versions 2.0, 3.0, 3.5 and one for .NET versions 4.0 and up.

For more information on installing dlls in GAC
http://msdn.microsoft.com/en-us/library/dkkx7f79.aspx

More information about the GAC
http://msdn.microsoft.com/en-us/magazine/dd727509.aspx

Read Full Post »

The content search web part is just brilliant. Not only does it let you aggregate, filter and find content and their metadata. The new way of styling with the new display templates is a huge relieve after all the xslt horror in the SharePoint 2007 and SharePoint 2010 versions.

One word of caution: I learned the hard way today that the Content Search Web Part is only available in the SharePoint Enterprise (on-premise) installation.

CSWPFeature

I hope that the nice  folk @Redmond change their mind about this and also make it available for the SharePoint Standard and SharePoint online versions.

The on-premise feature matrix can be found here:
http://technet.microsoft.com/en-us/library/jj819267.aspx#bkmk_FeaturesOnPremise

The online feature matrix can be found here:
http://technet.microsoft.com/en-us/library/jj819267.aspx

Back to the drawing board…

Read Full Post »

For some reason breadcrumbs are disabled in the default SharePoint master pages.  Luckily it is very easy to add them.

Add breadcrumb

Simply add this snippet to your master page or page layout

<!--MS:<asp:sitemappath runat="server" sitemapproviders="SPSiteMapProvider,SPXmlContentMapProvider" rendercurrentnodeaslink="false" hideinteriorrootnodes="true">-->
<!--ME:</asp:sitemappath>-->

And when loading your page again you should see something similar like this:
Crumb

Navigate up (breadcrumb fly-out)

If you are used to SP2010 or SP2007 you might also know the navigate up icon.  When you click it, a flyout appears with the breadcrumb

To add this one to your SP2013: edit the master page (or actually the html). Look for a div with the css class ‘ms-breadcrumb-top‘. In this div you find a SharePoint control called PopoutMenu.

Crumb2

For some reason this ‘PopoutMenu’ control has the  attribute ‘visible’ set to ‘false’. Remove the complete attribute or replace the visible=”false”  by Visible=”true”

The result will be an icon that when clicked results in a breadcrumb popout.

Crumb3

Read Full Post »

Ran into this helpful tool on Codeplex today. The SharePoint language pack downloader (http://sp2010dl.codeplex.com)

Manually downloading all the needed language packs from the Microsoft site can be handful. You have to download an extra pack when you have the SharePoint Server version installed. Multiply the amount of packs by 2 if you have a service pack installed. And you have to do this for all the required languages.

This can be confusing and if you don’t pay attention it’s easy to make mistakes. Luckily this tool downloads all packs automatically. A real time saver.

Read Full Post »

Here is a NLog config file that generates a similar log file layout as with the (default) Log4Net settings.

This NLog configuration also includes the date in the log file name to mimic the Log4Net ‘rollingFileAppender’ behavior.

file: NLog.config

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true">

  <targets>
    <target name="logfile" xsi:type="File" fileName="C:\Projects\logs\MainLog.${shortdate}.log" layout="${level:padding=-6}  ${threadid:padding=-4} ${processid}   ${longdate}  ${logger:shortName=true:padding=-24} ${message} ${exception:format=ToString,StackTrace}"/>
  </targets>

  <rules>
    <logger name="*" minlevel="Trace" writeTo="logfile" />
  </rules>

</nlog>

Read Full Post »

Good news!! JetBrains released the first version of their free decompiler tool, dotPeek.

Since the February 2011 the .NET community was looking forward for a new free decompiler tool after RedGate announced that their insanly popular decompiler tool ‘Reflector’ would no longer be free. Jetbrains reacted and is giving the .Net community: dotPeek.

DotPeek was already available with Resharper (beta) builds but now it’s also available as a standalone version!

Download the goodness here:
http://blogs.jetbrains.com/dotnet/2011/05/free-net-decompiler-is-available-for-early-access/

It’s free and supports .Net assemblies from version 1.0 to 4.0.

I’m a long time fan of JetBrains Resharper product. If the quality of dotPeek is equally good then RedGate Reflector will soon be forgotten. ;-)

Keep up the good work!!

Regards, W0ut

Read Full Post »

We have discussed the SharePoint 2007 SPDispose tool here before. A new version is now available with SharePoint 2010 support and a Visual Studio add-in.

In addition to dispose guidelines they have also added rules on when not to Dispose. For example you do not want to dispose your SPWeb en SPSite objects in your SPContext.

More information can be found on http://blogs.msdn.com/b/rogerla/ and on the SPDispose codeplex page.

Download is available on here on the Microsoft download site.

Read Full Post »

The Sharepoint team released a handy tool that helps you detect incorrectly (read: not) disposed objects.  It provides assistance in correctly disposing of certain SharePoint objects to help you follow the published best practice.

Best practice is to dispose you objects that inherit from the IDisposable interface.  There is more info  about disposing objects in SharePoint on the msdn site. Knowing when to dispose ( or when not to dispose)  can be tricky sometimes.

So when to Dispose? Shahil has 3 great rules to live by

1) Do not dispose objects you didn’t create. In other words, in a feature receiver, if “Parent” is SPWeb or SPSite – don’t be callin’ dispose on that. You didn’t create that object, and after your feature receiver is done, parts of the SharePoint framework may still need that object. This rule applies to general .NET.

2) Dispose is like a pretty girl, if you see it, call it… but don’t break rule #1. i.e. don’t call a pretty girl that isn’t confirmed unattached, .. if her large mammalian boyfriend finds out, he may knock your teeth out. This rule applies to general .NET as well.

3) If you call SPSite.Dispose, it will automatically call Dispose on all the contained SPWebs, thus unless you have an extremely borderline crazy logic that creates 200 SPWebs that you must dispose manually out of band, you should simply call SPSite.Dispose. This wasn’t the case in WSS 2 mind you!

On a side note: I recommend using “using” statements to dispose of objects (it is the easiest), but try catch blocks work also.

You can download the SPDisposeCheck tool here : http://code.msdn.microsoft.com/SPDisposeCheck

Read Full Post »

Lately I’m focusing myself on the ease of use of my code. I prefer that it is easy to read and maintain. I don’t mind if it’s not the best performing piece of coding. As long as it is logically stuctured, easy to read, implement the correct OO and design patterns and uses the same naming convention throughout the code, I stay a happy puppy.

During this strive to easier code I stumbled upon Stored Procedures. Not only are stored procedures difficult to maintain, difficult to read and debugging them can be quite a challenge as well. They also hide the business logic. If you want to see what is going on you will have to fire up your database client , browse for the stored procedure and look inside to know what is going on.

Changing.

I’ve worked upon quite some large web application projects and I know that it’s a pain to keep your dev environment in sync with the production server.   If your code is well designed, the stored procedure is only used in one place. But what if you have multiple projects that use the same database? Update all those projects at once?  Some keep different versions of their stored procedures.  Not very pretty indeed. A component which generates the SQL on the fly at runtime, doesn’t suffer from this: it will for example receive an entity which has to be saved to the database, that entity contains the new field, the SQL is generated and the entity is saved. No maintenance problems. With a stored procedure this wouldn’t be possible

Compiled.

And then you also have the stored procedure urban legend. “But they are faster because they are compiled!!!”.
Let’s put this straight: Stored procedures are not compiled. Although I can’t be too rude with my comments because I, myself, took this for granted for a way too long time.
Stored Procedures and ad-hoc queries are compiled on first execution. And both their execution plans are cached (yes also for ad-hoc queries) but compiled? No, sorry. Don’t believe me? Look it up in the SQL server documentation.

 

So what should we do? Putting our favorite SQL statements back in our code? Absolutely NOT!  But Stored Procedures are not the answer either.
However a component that generates SQL code on the fly is the future! There are many flavors available like NHibernate, .NetTiers, Ibatis, … and lately Microsoft is also doing their part to with the Entity framework (Linq).

I recommend looking into these and ditch those stored procedures. I say welcome our SQL generating overlords.

Read Full Post »

Apple hardware is getting popular, even in the .NET world. Just a few weeks ago a colleague bought himself a new Mac Book Pro, one of our project managers started asking weird questions about our ‘experiences’ with Apple hardware and our CEO is secretly using an iPhone 3G since a few weeks ( most of us here remember him as ‘critical’ for the iPhone when it came out :) ).  I even had some official Microsoft  SharePoint classes were the trainer was using a Mac Book Pro for his development.

Anyway, I was thinking that it might be a good idea to give a quick update on my .NET developing experiences on a Mac Book Pro. If you have read my previous post (back then it was on Blogger.com), I had some quirks.

My first impressions of visualization under Mac OS were not very positive. It worked but it was not workable.  A few months later, after reading some positive reviews about the new VMware Fusion, I decided to try again. I downloaded the new 1.1.3 version of VMware Fusion. And whow… what a difference.  They made major progress in speed and reaction time.  The quirks I experienced in the previous 1.0 version were all gone.  My biggest annoyance back then was that the intellisense and toolbox windows in Visual Studio were slow. They just didn’t pop-up or updated itself quickly enough to be workable.

After I completely configured the virtual image I did some tests. Booting up OS X and starting the virtual image with VMware Fusion was quicker than booting to Windows XP in Boot Camp.

So since 6 months I do all my .NET development under VMware fusion.  I even removed boot camp from my Mac book , nice to have that drive space back.
Make sure you have enough memory. I have 4GB of RAM in my Mac book, 2GB are used for my virtual development environment . For now this is sufficient, I still use Windows XP as my development OS.  If you use Vista you might want to add an other 512 Mb.

During the hollidays I ‘m planning to upgrade to VMware Fusion 2.0. It’s a free upgrade if you ever bought the 1.0 version!!! I will post my experiences as well.

Read Full Post »

Follow

Get every new post delivered to your Inbox.