Namespace issues when project is opened in Visual Studio 2012 Web Express

Topics: General, Writing modules
Jun 4, 2013 at 4:03 AM
Hi All,

With the intention to create a new module, I opened my Orchard project into Visual Studio from WebMatrix. It opened in Visual Studio 2012 Web Express, which is the only version of Visual Studio installed on my laptop.

I then created new module using Codegen command line utility. Though I had to create Drivers folder manually as it was not created by Codegen.

I then created a new class in Models directory and give namespace name as OrcRandD.Test.Models.

I then created a new class in Drivers directory, as I wanted to use Models classes here I added "using OrcRnadD.Test.Models". BUT it gives this error - "The type or namespace name '<Models>' does not exist in the namespace 'OrcRandD.Test' (are you missing an assembly reference?)".

I searched on Internet and found various solutions but they are not applicable in this case. Looks this is a specific issue between Orchard and Visual Studio 2012 Web Express.

Could you let me know the solution if you know of?

Thanks in advance.
Developer
Jun 4, 2013 at 9:22 PM
Looks like you made a typo:

Defined namespace_: OrcRandD.Test.Models
Imported namespace: OrcRnadD.Test.Models
Jun 5, 2013 at 2:55 AM
Thanks Sfmskywalker,

The typo was in my above description, not in the code. I am sorry for that.

Please find below the class definitions (copy pasted from original source)

\Modules\OrcRandD\Models\OrcRandDPart.cs

using System;
using Orchard.ContentManagement;

namespace OrcRandD.Test.Models
{
public class OrcRandDPart
{
    public OrcRandDPart()
    {
        //
        // TODO: Add constructor logic here
        //
    }
}
}

\Modules\OrcRandD\Drivers\OrcRandDPartDriver.cs

using System;
using Orchard.ContentManagement;
using OrcRandD.Test.Models;

namespace OrcRandD.Test.Drivers
{
public class OrcRandDPartDriver : ContentPart<OrcRandDPart>
{
    public OrcRandDPartDriver()
    {
        //
        // TODO: Add constructor logic here
        //
    }
}
}


It shows error where I have marked the text in bold in OrcRandDPartDriver.cs

Hope this will make things clear.

Regards,
CN
Coordinator
Jun 5, 2013 at 5:35 AM
As far as I know, Express doesn't allow for multiple project solutions.
Jun 5, 2013 at 4:35 PM
Hi BertrandLeRoy,

That doesn't seem to be the case.

I tried creating two projects in same solution in VS 2012 Express and it worked. Both compiled fine.
I also created same Orchard web site on another laptop running VS 2010 Professional but faced same problem.

The strange thing I noticed in both cases is, individual projects under Modules in solution explorer were not having project icon but just a folder icon. Also tree entry for References was missing in all of them.

This means somehow they are not considered a project and hence namespace is not working well.

I am digging further into it but let me know if you have any idea about the problem and the solution.

Regards,
CN.
Jun 5, 2013 at 5:31 PM
Edited Jun 5, 2013 at 5:34 PM
ChintanNaik wrote:
The strange thing I noticed in both cases is, individual projects under Modules in solution explorer were not having project icon but just a folder icon. Also tree entry for References was missing in all of them.
Are you opening the solution file (Orchard.sln file), or opening it as a website / opening the web project (Orchard.Web)? Make sure you are opening the correct solution file.

Multiple projects are allowed in express editions (since VS 2010 going by the comments)

BUT
Source
The only other limitation I have found so far is that opening solutions containing projects of various types is impossible. For example, opening a solution with a web project and a Windows 8 project will not work. Depending on which express product you are using (Express for Web or Express for Windows 8) one of the projects will fail to load and you will be unable to modify it. This is a rare scenario, at least for me, but I do know of a few projects that this would cause problems for. Of course, all three versions of Visual Studio Express support class library projects so you don't have to worry about that :)
Coordinator
Jun 6, 2013 at 2:41 AM
You created two web site projects in the same solution, or a web site project and a class library project in the same solution?
Jun 6, 2013 at 5:09 AM
Hi All,

I think I have got the problem. I created Orchard project using Web Matrix and then trying to create module in that project. BUT if I need to create module I need to get the full source of Orchard and then local clone it for the specific project.

This is a very basic thing but couldn't realize earlier as was creating my first project.

Regards,
CN.
Jun 6, 2013 at 6:15 PM
Hi All,

I downloaded full source and now everything is working fine. I am on the way to create my first module in Visual Studio 2012 Web Express.

Thanks for all your help which leads me to the problem identification and solution.

Regards,
CN.