Module with dependencies issue

Topics: Core, Customizing Orchard, General, Troubleshooting, Writing modules
May 8, 2013 at 6:44 PM
I am trying to develop a number of modules, but they are all dependent on a root module. But I am having a lot of trouble figuring out how to reference the root module.

When I try to access a ContentType defined in my root module in a dependent module controller things go bad.

I can not use the content type extensions As<> or is<> to get to my part even though I can see it in the debugger.

If I loop through the parts, and try and cast my "part" to its type I get the exception below:
2013-05-08 11:20:19,685 [5] Selectron.Administration.Controllers.AdministrationController - [A]Selectron.Jurisdiction.Models.JurisdictionPart cannot be cast to [B]Selectron.Jurisdiction.Models.JurisdictionPart. Type A originates from 'App_Web_js4pww0u, Version=, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\orchard.web\23006bf7\995acf5c\App_Web_js4pww0u.dll'. Type B originates from 'Selectron.Jursidiction, Version=, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\orchard.web\23006bf7\995acf5c\assembly\dl3\f03e4896\712b2a11_144cce01\Selectron.Jursidiction.dll'. at Selectron.Administration.Controllers.AdministrationController.Index(String id)

To try and address this I have tried numerous things.
A: Turning off dynamic compilation.
B: Putting root module in /orchard.web/bin
C: Adding web.config to dependent module with an assembly reference.
D: Adding a web.config in root module with an assembly reference. (This breaks the root module.)
D: Turning off Warmup Module.

I have lost at least a day on this, I can't be the first person who has had this issue.

Using Orchard 1.6.1 compiled from source.

May 8, 2013 at 10:21 PM
I think I have had a similar issue but it was about this time last year so the exact error is lost to my memory now.
In the Modules folder do a search for "bin" and "obj" folders and delete them (or from the orchard.web directory). Clean the solution. Rebuild the solution. Hopefully lots of incorrect references arise where it has taken them from the 'bin' folders from previous builds and then referenced them (and continued using those old references if the path is incorrect for example).

I've has similar issues with other project types (MVC applications, webforms) where the temp file directory were acting odd too (caching older precompiled dlls). I think that just required force deleting those folders. It hasnt happened to me in .net version 4+ though. <-- So very long shot
  • %systemroot%\Microsoft.Net\Framework\v4.0.30319\Temporary ASP.NET Files
If i think of anything else I will post some more.
May 8, 2013 at 10:56 PM
I develop in another directory, and then in my post build event delete the my modules directory, and put it back in place in orchard.web/modules. I am not bring the obj directory during my copy.

I have been manually deleting the application folder in Temp ASP.NET between builds for a while now.

None of those has helped.

Thanks for the suggestions.
May 9, 2013 at 8:02 PM
I sort of figured it out.

I was developing dependent modules in a separate solution from the root module. The references to the root module were manually browsed to. When all the modules were put into a single solution and the dependencies referenced through the project things got better.

Still having some strangeness regarding dynamic compilation loading vs precompiled loading but at least I am working now.
May 9, 2013 at 8:15 PM
Edited May 9, 2013 at 8:15 PM
Just reference the project (not the compiled binary). Also, make sure you declare the feature dependencies in module.txt.