Showing posts with label DotNetNuke. Show all posts
Showing posts with label DotNetNuke. Show all posts

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.


Sunday, June 12, 2011

Building DotNetNuke 5.6.2 Source with Visual Studio 2010 Professional

This weekend, I have finally decided to download the DotNetNuke Community Edition source code and decided to build it with Visual Studio 2010 Professional Edition.

It took several trial and errors so I am going to write down what has worked, mainly so that the next time I will remember how I did it and worked.
  • If you are on Windows 7 (and should be), be sure to permanently enable the Visual Studio to run as Administrator. This will save a lot of time re-running it as DNN projects install and configure IIS 7 and that requires an elevated privilege. If I tell you to just open the  privilege setting is in the Property of the Shortcut, then you know how to set this up even if you have not done that before. Still not making sense? See this Technet KB Article
  • Make sure you have a working SMTP server. You will most likely need to setup an email address then a password which is usually needed for modern SMTP servers.
  • Unzip it to Some Simple Directory, like C:\DNN  You will be editing the solution file pointing to this new location. When the solution loads, it will create a Virtual Dir on IIS 7 (that means you have to install IIS 7 beforehand
  • Add Web Management Tools -> IIS 6 Management Compatibility -> IIS Management Console AND IIS Metabase and IIS 6 configuration compatibility
  • Under the World Wide Web Services -> Application Development Features, ASP.NET should be added.
  • Make a first backup copy of the Unzipped version to somewhere safe. You will likely mess up the next step and will likely accidentally launch the solution (.sln) file before the required hand-edit,and corrupt it beyond repair.
  • Don't Launch the Solution File yet. You need to hand-edit it first.
    • Text Edit the Web Root name (the line that has http: in it) to something short and sweet like http://localhost/dnn  
    • To make sure you don't do an accidental start of the project, edit the solution file using Notepad by starting the Notepad then do the File->Open.
    • Go and find any places that has E:\blah\blah on it, and make the change that correspond to where you put the unzipped directory.
    • But don't change where it says VirtualPath that will break the loading of the web project.
    • If none of the above is making any sense to you, then definitely make a backup of the solution file before you do anything  and ask someone who might know.
  • On IIS if you don't have one create an Application Pool to .NET 4.0 Framework
  • Set the Application Pool User to Network Service. This can be done in the Advanced property menu. It is a lot simpler for me to use the Network Service than something else especially on a local develop machine. By default the Application Pool it uses is the Default Application Pool.
  • Give Full R/W permission to Network Service for the entire DNN tree.
  • Backup the DNN Directory to Another Directory. If you (are likely to) fail after the following steps any work you have done won't go to waste.
  • Now you can launch the Solution, and let it build. This should go smoothly.
  • Create a Database
  • Create a login account for the database on the SQL (Express) server and assign the dbo capability to the account. 
  • Copy development.config to web.config
  • Set the web project as the startup (this should be indicated as the URL you specified when you edited the solution file.)
  • Go to IIS Admin and make sure that the Virtual Directory is pointing at "Website" directory within  the  DNN development directory tree and assign the Application Pool that is running the .NET Framework 4.0
  • Then start the the debug session of the web project.
  • If everything compiles fine and the web site runs OK, then exit the Visual Studio, make a backup copy of the entire directory. In fact, you should always do this before a major change to your project, such as adding or removing a project. It is also a big time saver to back up your DNN database prior to making a major change to the DNN configuration, such as adding or removing a module.
Failure Recovery

The initial debug run goes exactly like installing a brand new site. If the startup jams during SQL script part, then without a hesitation, drop the database and create a fresh one. There will be some unfinished stored procedure or other stuff dangling and it won't install the second time.

Teralic Installation Issues during setup: I ignored this issue and the site is working fine. I will report if there will be issues.