Error when cloning ContactForm

This is an open forum for any mojoPortal topics that don't fall into the other categories.

This thread is closed to new posts. You must sign in to post in the forums.
8/17/2011 4:17:35 PM
Gravatar
Total Posts 38

Error when cloning ContactForm

Hi all,

I'm trying to clone the ContactForm-feature to be able to make a few changes. I've followed the documentation "Cloning an Existing Feature" and everything seems to be ok except for some minor errors (I think as I'm a newbie in both Mojo and C#).

When I build the solution I get the errors "The name 'ContactFormMessage' does not exist in the current context" and "The name 'myContactFormResources' does not exist in the current context"

I've looked through all references and using directives but I can't get it to work. What am I missing?

One more question - how do I reference to log4net? Can't find this reference in "Add reference".

Best,

Anette

8/17/2011 6:56:41 PM
Gravatar
Total Posts 245
mojoPortal Community Expert

Re: Error when cloning ContactForm

Hi Anette

In the mojoPortal source code project there is a mojoPortal.Features.Business project.  Look in there and you will find a folder called ContactForm.  In that folder is a file called ContactFormMessage.cs.  It is this forms class reference your project can't find.

I would copy this file to your clone features Components folder and rename it MyCloneFormMessage.cs or whatever you call your project and then change the reference name to it's ContactFormMessage class in your files on a line that looks like this...
Line 108 - ContactFormMessage contact = new ContactFormMessage();

That should lead you in the right direction for the first error.

Your clone project should have it's own App_GlobalResources folder with it's own MyCloneFormResources.resx file in it.  This file should be a copy of mojoPortal.Features.UI\App_GlobalResources\ContactFormResources.resx

If you rename the reference file and/or the reference names in it, then and all references to ContactFormResources (lots of them) should be changed to whatever you name your projects resource file. Also, your resource file must be targeted in your features setup folders config files.

That should lead you in the right direction for the second error error.

For the log4net error...

In the source code in the mojoPortal.Web project there is a dll called log4net.dll in the bin folder.  Create a reference to that dll in your feature.

Hope this helps.

Every developer will clone a project slightly different than the next based on the developers experience and the complexity of the changes being made to the cloned feature.  My advice to you probably differs from others but it has worked for me.  Database changes will definitely take your cloning to a much higher level of complexity.

Good luck and have fun

Rick Hubka

 

 

8/18/2011 11:38:17 AM
Gravatar
Total Posts 38

Re: Error when cloning ContactForm

Thank you for your quick answer - and the log4net- problem is now easy solved!

But I still have problems with the references.

I had done exactly as you describe - copied the ContactFormMessage.cs file to  myProj.Business-layer, made a reference to myProj.Data.MSSQL (instead of mojoPortal. Features.Data.MSSQL) and in the file I changed "using mojoPortal.Data" to "using myProj.Data" and also changed the namespace from mojoPortal.Business to myProj.Business.

I didn't however change the name of the file or the class name (ContactFormMessage). I've tried it now but it doesn't help. I must be overlooking something??

It's the same with the resourcefile - I have copied and renamed it and changed all the references to it in the other files as well as in the config-file in the FeatureDefinitions-folder. So I must have missed something else?

::Anette

8/18/2011 3:00:28 PM
Gravatar
Total Posts 245
mojoPortal Community Expert

Re: Error when cloning ContactForm

Hi Anette

Since you are new to mojo and C#, the easiest way to get you up and going quickly is to give you my complete working clone the ContactForm-feature.

Just unzip it and add this project file to your solution and you'll have a working copy.  I did the clone all in one project.  From there you can either use mine as an example to copy from or change the file names and do a big search and replace on the word "GarageWizard".

Here is the clone zip file on a mojoPortal Website I'm working on.  It's big 16 Meg file because the bin file has all the dlls the clone needs for mojo 2.3.6.7

Download Clone of ContactForm-feature here *** updated.

Good Luck

If anyone else wants it feel free to take it before it's gone.

BTW.  It's complete and compiles clean and install tested.

Rick Hubka

8/18/2011 4:49:03 PM
Gravatar
Total Posts 55
mojoPortal Community Expert
Arvixe Web Hosting / mojoPortal Community Liaison Looking for quality mojoPortal hosting? Try Arvixe Check out the MojoPortal Blogs at Arvixe

Re: Error when cloning ContactForm

That sounds like it will be very useful Rick, so hope you don't mind I've taken a download to look at when I get a chance.

8/19/2011 2:45:44 AM
Gravatar
Total Posts 38

Re: Error when cloning ContactForm

Thank you so much Rick, I will download it and compare with my files to see what I have done wrong.

::Anette

8/21/2011 11:39:39 AM
Gravatar
Total Posts 38

Re: Error when cloning ContactForm

Hi, sorry I have to write to you again. I've made a new clone from the start and everything seemed to work fine, I built without any errors and the setup worked. I can see the feature in the list and the database table is also there. But when I try to install the feature on a page it doesn't show. When I try to reach it through settings and preview I get the following error in the log:

ERROR 213.67.42.63 - sv-SE - /Admin/ContentManagerPreview.aspx?mid=43 - mojoPortal.Web.Global - 213.67.42.63 /Admin/ContentManagerPreview.aspx?mid=43 Referrer(http://www.qaccept.com/Admin/ModuleSettings.aspx?mid=43&pageid=24)
System.Web.HttpParseException (0x80004005): Could not load type 'Kontakt.Web.ContactUI.ContactForm'. ---> System.Web.HttpException (0x80004005): Could not load type 'Kontakt.Web.ContactUI.ContactForm'.
   at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError)
   at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly)
   at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData)
   at System.Web.UI.TemplateParser.ProcessException(Exception ex)
   at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
   at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)

 

Very much appreciate your help,

Anette

8/21/2011 1:23:30 PM
Gravatar
Total Posts 245
mojoPortal Community Expert

Re: Error when cloning ContactForm

I can't be sure, but it looks like your mojoPortal Web solution can not find the dll's from your custom feature.

In Visual Studio, right click on your project file and click properties.
Then on the properties page click the "Build Events" tab.  In the "post-build event command line" you should have code similar to this (below) which will copy your files and dll's to your features folder in the mojoPortal Web project.  This folder must also be the same folder referenced in your setup config file.

xcopy /s /y "$(ProjectDir)bin\GarageWizard.UI.dll" "$(SolutionDir)Web\bin\"
xcopy /s /y "$(ProjectDir)GarageWizard\*.aspx" "$(SolutionDir)Web\GarageWizard\"
xcopy /s /y "$(ProjectDir)GarageWizard\*.ashx" "$(SolutionDir)Web\GarageWizard\"
xcopy /s /y "$(ProjectDir)GarageWizard\*.ascx" "$(SolutionDir)Web\GarageWizard\"
xcopy /s /y "$(ProjectDir)App_GlobalResources\*.resx" "$(SolutionDir)Web\App_GlobalResources\"
xcopy /s /y "$(TargetPath)" "$(SolutionDir)Web\bin\"
xcopy /s /y "$(ProjectDir)Setup\*" "$(SolutionDir)Web\Setup\"

This is covered in one of Joe's Developer videos.

I hope this helps???????
 

8/21/2011 4:53:44 PM
Gravatar
Total Posts 38

Re: Error when cloning ContactForm

Hi,

I've had done all that - the build events are all there and the dll's are in the bin-folder. I will struggle with it by myself, but do you have any other ideas?

But first a good nights sleep - it's midnight now in Sweden!

::Anette

8/22/2011 2:11:46 PM
Gravatar
Total Posts 245
mojoPortal Community Expert

Re: Error when cloning ContactForm

Hi Anette

I updated my Download Clone of ContactForm-feature file in my post above.  I tested it and it did not work.  I needed to fix a couple of words in the resource file and the setup config file.  I just tested it and it installs fine on a new page now as an exact clone.

Download it again and add this clone project to your main mojo solution.  Compile it so the post-build script does it's thing.  Then in your VS mojoPortal.Web project in the setup folder right click on Default.aspx and set it as the start page and run the solution.  As the script runs you will see a line called Garage Wizard.

Then in your website add a new page and add the Garage Wizard feature to it.  Then check it out.  It's a copy of the Contact form.

In your feature make sure feature name in the setup config file and the feature name in the resource file are correct.  That was my error and why it did not install correctly at first.

Now you have a working/tested clone project to compare.

When building a new mojoPortal feature module I have found out the hard way...  At first, don't build anything into it until it installs and works basically empty.  Take baby steps at first and just do a new feature that says "Hello world!" or in the case of a clone, don't add anything to it until it works as a simple clone first.  Don't code for hours and add 10 new things.  Instead, add 3 new things and run it every 20 minutes.  Same goes for adding database scripts.  Don't script and add 10 tables and 20 stored procedures at once.  In my scripts I have one script file for tables, one for stored procedures, one for functions, etc.  This is the best way to avoid compound/multi errors which are exponentially more difficult to find.

On your second and third feature then you can take bigger steps.

Good luck.

11/7/2011 11:18:19 AM
Gravatar
Total Posts 51

Re: Error when cloning ContactForm

Hi Rick, please could you post your project of "clone contactform" again? It´s gone -:(

I´m trying to add some field to the table in my cloned feature, but I fail. I therefore need to learn from your example.

Thanks

 

P.S: I´m trying to build a booking form with fields: bookingDate, bookingValidity, Product...

You must sign in to post in the forums. This thread is closed to new posts.