Monday, July 18, 2011

DotNetNuke 5 Module Development Tips with Visual Studio 2010

I am jotting down some things I need to remember to know when starting a new C# DotNetNuke module development using the Starter Kit, most of the steps are described elsewhere, notably HERE, but sometimes they contain  wrong information in the original text that you need to dig through the user comments to find out the solution. Also there are a few key things I need to remember to do every time.

Local IIS is a Must for a Newbee DNN Module Developer

Install the base DNN in the local IIS and get that going completely first. It will complicate less for module development as it will need to look up images and other resources in the directory structure.


Where To Store The Project?

The best place seems to be within the DesktopModules folder, create a project directly in there. Then all the references are good to go. By the way, target your project to .NET 3.5

Be sure to uncheck Create Solution Folder box when creating a project in this manner.


What To Type into The Assembly Name and Default Namespace?
  • Type in the same info on both field by replacing YourCompany in the Assembly Name part with what you do, and then copy and paste that to the Default Namespace. This is for C#. I don't know VB at all so I will leave that up to you for VB.
  • Do not do a Globally Replace of YourCompany to whatever. See below!

Do Not Globally Replace YourCompany With Your Real Company


You will get the following type of error message from Edit....ascx.deginer.cs  if you immediately try to compile the project.

DotNetNuke Error 11 'System.Web.UI.UserControl' does not contain a definition for 'Text'

The reason why this happened was that global::DotNetNuke.UI. classes was inadvertently changed by the Visual Studio to global::System.Web.UI

How To Replace YourCompany


Note that order in which this is done is very important. Do not do these in out of sequence.

  1. Make a backup copy of the module project folder so that if you mess these steps, you can get them back.
  2. Open any of the classes in the control. And on the Namespace, right click over YourCompany and use the Refractor menu to change this to whatever you like.
  3. Open the Manifiest file (the one that ends with .dnn). On this one Replace YourCompany. with empty string. This fixes the install folder name from YourCompany.YourModule (make sure that the path does match with how you created your module root directory in the DesktopModules folder.
  4. Save everything.
  5. Make a backup copy of this folder again.
  6. You can now Quick Replace the rest of the files containing YourCompany (for example SQL Provider files). Use the Quick Replace at the Solution level.

Configure the Project's IIS

Next Configure the Project to Use the Local IIS Server so that images, controls and other resources in your development environment. Otherwise, your design surface will have errors. Also if any of the controls on the design surface errors out with a COM error, that means you probably did not follow my previous steps to refactor the classes properly which swapped the controls to the system default ones (not DotNetNuke.UI.Control ones), and ended up globally replacing YourCompany in the classes. You need to start over the project and follow the steps.
  1. Open the project property
  2. Select the Web tab on the left.
  3. Select "Use Local IIS Server"
  4. In the project URL, point it to the URL of your project within the DesktopModules folder. For example, http://localhost/DNN/DesktopModules/MT3 would be that I have the module project named MT3, and I have installed the DNN root at localhost/DNN
  5. Click Override application URL and type in the base URL for the DNN, for example, on my machine it is http://localhost/DNN
  6. This will also create web.config files in the folder which will interfere with the module loading. Rename it to xweb.config just in case you need it in the future.
Debugging

If everything is set right and the DNN itself is a debug version then you can attach to the IIS process w3wp.exe locally and you should be able to set a breakpoint in the project. I will write more as I find out how to do this a bit better without needing to rebuild the DNN from the source.


No comments: