Handling Exception in DotNetNuke Modules menu

For development, I use a couple of DNN 6 installations. Today I tried to import and use a newly created module, when the Modules menu displayed the following error text at the bottom:

An error has occurred.
DotNetNuke.Services.Exceptions.ModuleLoadException: An entry with the same key already exists. ---> System.ArgumentException: An entry with the same key already exists.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.SortedList`2.Add(TKey key, TValue value)
   at DotNetNuke.Entities.Modules.DesktopModuleController.GetPortalDesktopModules(Int32 portalID)
   at DotNetNuke.Web.UI.WebControls.DnnModuleComboBox.GetPortalDesktopModules()
   at DotNetNuke.Web.UI.WebControls.DnnModuleComboBox.BindAllPortalDesktopModules()
   at DotNetNuke.UI.ControlPanel.AddModule.LoadModuleList() in c:\projects\dnn060104\admin\ControlPanel\AddModule.ascx.cs:line 395
   at DotNetNuke.UI.ControlPanel.AddModule.LoadAllLists() in c:\projects\dnn060104\admin\ControlPanel\AddModule.ascx.cs:line 327
   at DotNetNuke.UI.ControlPanel.AddModule.OnLoad(EventArgs e) in c:\projects\dnn060104\admin\ControlPanel\AddModule.ascx.cs:line 133
   --- End of inner exception stack trace ---

Digging through the DNN6 source code, I found the DesktopModuleController class in DotNetNuke_Community_06.01.04_Source \Library \Entities \Modules \DesktopModuleController.cs, where the GetPortalDesktopModules(int) method converts the results of GetPortalDesktopModulesByPortalID(int) into a SortedList<string, PortalDesktopModuleInfo>, the Add() method of which raised an exception, because a FriendlyName collision.

To find the offending modules, use SSMS to navigate to your DNN database, right-click the DesktopModules table and select “Edit top (n) records”. Press the SQL toolbar button and modify the SELECT statement to ORDER BY FriendlyName.

SELECT     TOP (200) *
FROM         DesktopModules 
ORDER BY FriendlyName

Rename one of the FriendlyName values causing the problem.

Next, update the web.config to cause DNN to reload its caches.

Problem fixed 😉

2 thoughts on “Handling Exception in DotNetNuke Modules menu

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.