aDEFWEBSERVER
Los Angeles, CA *  Webmaster@ADefWebserver.com

 

Creating a DotNetNuke® Module using notepad -
For absolute beginners! (Page 3) page 2

 

Changing the module:

 

You are now ready to make a change to the module and view the change.  In the file "ImportantMessages.vb" find the line:
 

lblHelloWorld.Text = helloText

and change it to:

lblHelloWorld.Text = helloText & "<i> - The time is now " & DateTime.Now.ToString() & "</i>"

Save the file and click the TEST tab in DNN in your web browser. You will now see the current time appended to the message.

 

Dealing with Problems

 
You will have problems when developing your module. you will make typos and you will simply write code that will not do what you want it to do.

I stress that it is best NOT to develop a module using notepad. This tutorial is only to get you started. I recommend that you get a copy of Visual Studio 2003 (you can get a cheap copy on Ebay) and use the DAL builder program available at DotNetNuke.dk. This is the setup I use.

This tutorial is meant to simply get you started. However I realize that you will probably want to "try some things out" to express your "creativity" and you will probably then get an error message. I will attempt to help you resolve this but please keep in mind the real solution is to use a proper tool such as Visual Studio to develop your modules.


Compiling and Debugging

 
The problems that you experience will deal with either compiling or debugging, and in that order. Your code must first compile before anything else can happen. If it doesn't compile you can't debug.

Therefore, I will show you how to compile using the "command line".

(This tutorial was created for Windows 2000. WindowsXP and Windows 2003 may have differences with the instructions that follow. If anyone discovers these please email me)
.

 

First, make a copy of "DotNetNuke.dll"

(this is found in the "bin" directory of the DotNetNuke installation, usually at "C:\Inetpub\wwwroot\DotNetNuke\bin").

and place it in your development directory at: "C:/Inetpub/wwwroot/DotNetNuke/DesktopModules/ShowMessages".

Next, make sure you are able to use the "command line compiler". To test this, open the command prompt and type "VBC".

(The command prompt program is usually located in your Start/Programs/Accessories directory or click on your START button, select "Run" and type "CMD" (if you are using Windows 2000))

If windows is able to find the program (because there is an entry in your "path" settings that allows windows to find the "vbc.exe" program) then you can proceed, otherwise you need to add "vbc.exe" to your path settings.

You can get help HERE to fix your path setting.

   

Compile "ImportantMessages.vb"

 
This first thing is to see if you can compile "ImportantMessages.vb" into "ImportantMessages.dll". If "ImportantMessages.vb" will not compile, the compiler will tell you why and you can fix the problem and try to compile again. Your module will not work in DotNetNuke if it will not compile.

Whenever you make a change to the "ImportantMessages.vb" file and DotNetNuke shows you an error, first try to compile it using the instructions below, then try to debug the "ImportantMessages.vb" file.

First, open up a new instance of NOTEPAD and type:

vbc /t:library /r:system.dll /r:system.web.dll /r:system.drawing.dll /r:DotNetNuke.dll ImportantMessages.vb

pause

Save this file as: "compile.bat" in your
"C:\Inetpub\wwwroot\DotNetNuke\DesktopModules\ShowMessages" directory. (make sure you haven't accidentally named it  "compile.bat.txt")

Now double-click on "compile.bat" and it will compile "ImportantMessages.vb" and create "ImportantMessages.dll"



(Pause was added to the batch file so you can see any errors that may have occurred.)

In the example to the right, I changed the line:
Imports DotNetNuke.Services.Exceptions
to
Imports DotNetNuke.Services.Exceptions1

This means the "ImportantMessages.vb" will not compile and you can see the error message displayed.

Your other compiling errors will probably consist of missing references. The current example contains these references:

Imports System
Imports System.Drawing
Imports System.Web.UI.WebControls
Imports DotNetNuke
Imports DotNetNuke.Common
Imports DotNetNuke.Services.Search
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Entities.Modules.Actions
Imports DotNetNuke.Services.Localization
Imports DotNetNuke.Services.Exceptions

Therefore this line will compile the example:

vbc /t:library /r:system.dll /r:system.web.dll /r:system.drawing.dll
 /r:DotNetNuke.dll ImportantMessages.vb


If you add or change the references you will have to add to or change the
 "/r:" references when you compile.

 


Debug "ImportantMessages.vb"

 
Read this Article on using the CLR to debug.  
   
If you have read the above article you have now:
1. Installed the .NET SDK if you did not already have it.
2. Found the "DbgClr.exe" program (usually at C:\Program Files\Microsoft.NET\SDK\v1.1\GuiDebug\DbgClr.exe)
 

We will now walk through debugging our example.

First, make sure the "ImportantMessages.vb" will compile when you run the "compile.bat" file. You cannot debug if the file will not compile.

Next, open up the "web.config" file in the root directory of your DotNetNuke program and make sure the compilation debug key is set to "true" (case matters, use lowercase).

<!-- set debugmode to false for running application -->
<compilation debug="true" />

Next, open up your DotNetNuke web in your web browser and select the tab that contains our example module. This will start the aspnet_wp.exe or w3wp.exe (for Windows 2003) process running.

Next, start the DbgClr.exe program.

In the DbgClr program, select FILE then OPEN then FILE and open "ImportantMessages.vb" (Do NOT open "ImportantMessages.dll")

 

After the file opens, Click in the border to the left of the line:

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

A red dot will appear. This will set a "break point" that tells the compiler to start debugging here.

Now select TOOLS then DEBUG PROCESSES.

 

Check the box next to Show system processes.

Then double-click on aspnet_wp.exe (or w3wp.exe for Windows 2003) and then click CLOSE.

Now switch to your DotNetNuke site in your web browser and click the tab that contains the test module. This will cause it to reload.

The debugger will now take over.

You can press the F11 key on your keyboard to step through the code.

 

You can use the shift+F5 to stop debugging or click the stop button on the debugging toolbar.

To start debugging again you must start all the steps above.

   

We are now ready to compile and package the DNN module.

 

Next... compile the module

3 of 5


Buy DotNetNuke Modules from Snowcovered

(C) by Michael Washington - ADefWebserver.com - Webmaster@ADefWebserver.com

DotNetNuke® is a registered trademark of Perpetual Motion Interactive Systems Inc.