NullReferenceException in DotNetNuke 7 FriendlyUrlProvider

A recent client was having trouble with their DotNetNuke site search following an upgrade to version 7.  For some queries, the search function would return no results found even when there were a number of modules whose content it matched.  For others it would work just fine.  Deleting and re-indexing the search content still returned the same result.

The Event Viewer for the portal contained the following error:

System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.Entities.Urls.BasicFriendlyUrlProvider.FriendlyUrl(TabInfo tab, String path, String pageName, PortalSettings settings) at DotNetNuke.Services.Url.FriendlyUrl.DNNFriendlyUrlProvider.FriendlyUrl(TabInfo tab, String path, String pageName, PortalSettings settings) at DotNetNuke.Common.Globals.NavigateURL(Int32 tabID, Boolean isSuperTab, PortalSettings settings, String controlKey, String language, String pageName, String[] additionalParameters) at DotNetNuke.Services.Search.Controllers.ModuleResultController.GetDocUrl(SearchResult searchResult) at DotNetNuke.Services.Search.Controllers.SearchControllerImpl.GetSecurityTrimmedResults(SearchQuery searchQuery, LuceneQuery luceneQuery) at DotNetNuke.Services.Search.Controllers.SearchControllerImpl.GetResults(SearchQuery searchQuery) at DotNetNuke.Services.Search.Controllers.SearchControllerImpl.SiteSearch(SearchQuery searchQuery) at DotNetNuke.Web.InternalServices.SearchServiceController.GetGroupedDetailViews(SearchQuery searchQuery, Int32& totalHits, Boolean& more) at DotNetNuke.Web.InternalServices.SearchServiceController.Search(String search, String culture, Int32 pageIndex, Int32 pageSize, Int32 sortOption)

I downloaded the DotNetNuke source package and was able to determine that the error was caused by a null value being passed to the friendly URL provider for the portal alias associated with the site.

The fix was simple.  There was no default portal alias set for that site.  I updated the portal alias record in Site Settings under the Admin menu and I was able to see the missing search results.

It is possible that after the upgrade there was something with the portal aliases that was saved improperly and it just needed a refresh.  Nonetheless, I wanted to provide my steps to fix the problem in case it helps.

Thanks for reading!  Leave a comment and let me know if this fix works for your site.

.NET Decompiler Software Options

Every once in a while a project comes along that requires integrating with a third-party library or working with existing compiled code.  On occasion those libraries can come with either poor or no documentation at all.  This can make debugging a nightmare.  In this case, having a peek at the source code can point you in the right direction or even solve the problem altogether.  Believe it or not, there are several solutions available for decompiling .NET code on any budget, including many that are completely free.  You can even (gasp!) make changes to the library and re-publish!  Here is a look at the options.

Red Gate .NET Reflector

Reflector was previously the only solution available for decompiling .NET assemblies.  They offer a complete desktop application and an option for Visual Studio integration.  I say “previously” because .NET Reflector recently switched to a paid application, which spurred many of the competitor products.  Pricing for Reflector starts at $95.

Jetbrains dotPeek

dotPeek is my favorite .NET decompiler application.  It has a clean, familiar design and also has many IDE-like features for navigating through the decompiled code.  My only complaints are that it only decompiles to C# code at the moment and that it does not allow direct editing of the library.  You can however save the code as Visual Studio project and rebuild it on your own.  Best of all, it’s free.

Telerik JustCompile

JustCompile has many of the same features as dotPeek including the ability to create Visual Studio projects.  It is also very fast and provided free of charge.  I ended up using JustCompile for a recent project because it is compatible with Reflexil, a plugin that allows you to directly edit the library.  It is not as simple as just writing new code, but it is very helpful for situations where you just need to make small changes and don’t want to rebuild.  (Note: Reflexil also works with Reflector, but JustCompile is the only free application that it supports.)

CodeReflect

CodeReflect is a decompile-only product, meaning that it does not provide any of the Visual Studio project features of some of the other options.  It has a very simple interface and is also free of charge.  CodeReflect can decompile .NET code into either VB.NET or C#, whichever you prefer.

ILSpy

I have not used ILSpy, but I wanted to include it in the roundup since it is the only open source .NET decompiler.  ILSpy can decompile to either VB.NET or C# and save as a project in C#.  If you are a developer who is curious about decompiling, you can check out the source code to learn how it all works.

Thanks for reading.  Do you have a favorite .NET decompiler that is not on the list?  Feel free to leave a comment!