The Engage Weblog

C# Compiled DotNetNuke Module Template

by Brian Dukes on Tuesday, October 7, 2008 8:32 AM

It shouldn't be hard to get started writing a module for DotNetNuke, but it doesn't seem like there's a whole lot of help especially when you are wanting to use C#.  At Engage, we have created a Visual Studio project template which will get you started developing a C# DotNetNuke module, using a Web Application project (rather than the, in my opinion, much more cumbersome Web Site project).  It is available for free on our downloads page after registering on the site.

The template will get you started with the basics of a DotNetNuke module, providing basic placeholder controls (for view, edit, and settings), base classes to use for your module controls and your settings control, a manifest and NAnt build file to easily package your module, and the basic starting point (and sample code) for your business controller class and data provider.  It should really speed up how you start a new module, and free you from always copying your last module and then having to figure out what to delete and what to leave.

To use the template, put the downloaded zip file into the C# web templates folder for Visual Studio.  This is typically in My Documents/Visual Studio [2005|2008]/Templates/ProjectTemplates/Visual C#/Web (you might have to create the Web folder yourself).  This will make the new project type appear under the Web node for C#, in the My Templates section, when you create a new project.  You might also want to open up the zip file and alter the template manifest (C# Compiled Module.vstemplate) to include your company name (replace the values in the CustomParameters section where it says YourCompany).

Please check it out, we hope it helps you out.  Happy module building!

Blogs Parent Separator Brian Dukes
Author
Brian Dukes

Brian Dukes has been working with Engage professionally since 2006, but has been writing code since around 1998. Brian is very passionate about writing code that is easily maintainable, and helping others to do the same. He has been a leader in the DotNetNuke Community, and can often be found speaking at conferences and helping others on twitter, github, and stackoverflow. DNN recognized his community efforts by awarding him the DNN MVP in 2012. Outside of work, Brian spends time with his family, serves Jesus at City Lights Church, as well as supporting social justice, fair trade, local, seasonable food, and international adoption.

11 comment(s) so far...

Anonymous 3/8/2009

Thnaks for this. I am trying it now.<br><br>The Nant build fails looking for the solution file. If I amemd the build script to look in the parent folder it works. There are a few ways this could be done:<br><br> 1 Modify the subproject.name variable to be prefixed with ../<br> 2 Modify the compile target similarly<br> 3 Create a new variable subproject.dir and use that in the compile target<br> 4 Ways I haven't thought of ...<br><br>What would you think is the best way to fix this?<br><br>Regards<br><br>Neil<br><br><br>

 
Anonymous 5/6/2009

thank you for this source code <br>i hope it will help me to build my module

 
Anonymous 11/18/2009

Hi, when I build the project, it says dotnetnuke namespace could not be found? do I need to add reference to your engage.donetnuke.dll?<br><br>thanks,<br>-gil

 
Brian Dukes 11/18/2009

gil, <br>The project has a reference to the main DotNetNuke.dll assembly in your website. You may need to remove and add that reference back, if it isn't at the default path that the template assumes.<br><br>Hope that helps,<br>-Brian Dukes

 
Anonymous 12/1/2009

Hi, thanks for your sharing.<br>is this usable for the DNN 5?

 
Brian Dukes 12/1/2009

Ahmet,<br>A module created with this template should still continue to work in DNN 5. If you're building a module solely for DNN 5, you can update the reference to Dotnetnuke.dll, and it should work fine. If you want the module to work in both DNN 4 and DNN 5, you'll just need to make sure to test the module on DNN 5 to make sure you aren't trying to do something that does work anymore in DNN 5.<br><br>The only issue with the template will be that the module's manifest is still in the DNN 4 format, so you would want to update that to the DNN 5 format (or keep the DNN 4 format and add another manifest for DNN 5, if you want to support both versions).<br><br>Hope that helps,<br>Brian Dukes

 
Anonymous 1/20/2010

Getting the error unable to read project the default XML namespace of the project must be msbuild XML namespace.

 
Anonymous 1/20/2010

Cannot seem to get this to load in vs 2008

 
Brian Dukes 1/20/2010

Just dropping that .zip file into C:\Users\bdukes\Documents\Visual Studio 2008\Templates\ProjectTemplates\Visual C#\Web makes it available to me when I go to File->New Project. When you updated the company name in the manifest, could you have accidentally changed something else?

 
Anonymous 2/26/2013

Need C# Compiled DotNetNuke Module Template for VS 2010

 
Brian Dukes 2/26/2013

For newer DNN C# compiled templates, check out Chris Hammond's project at <a href="https://christoctemplate.codeplex.com" rel="nofollow">christoctemplate.codeplex.com</a>. The latest VS 2010 release is at <a href="https://christoctemplate.codeplex.com/releases/view/93348" rel="nofollow">christoctemplate.codeplex.com/releases/view/93348</a>