This project is read-only.

Module dependency adding

Topics: Writing modules
Aug 2, 2011 at 4:02 PM
Edited Aug 2, 2011 at 4:13 PM

I'm trying to add a dependency to Orchard.Blogs and it causes my module to not be loaded into the ~/app_data/dependencies/dependencies.xml list.

In my module in VS I made a reference to the dll at ~/Modules/Orchard.Blogs/bin/Orchard.Blogs.dll. On my development machine it seems to work fine. When I publish to the live machine, it acts funny.

If I have a copy of Orchard.Blogs.dll at ~/Modules/MyModule/bin/Orchard.Blogs.dll (copy local set to true), the module is not loaded up at all (it's not in the ~/app_data/dependencies/dependencies.xml list).

If I remove the Orchard.Blogs.dll from my module's bin (copy local set to false), MyModule is loaded into the dependencies.xml file but gives me YSOD when I try to invoke a controller in the module: Could not load file or assembly 'Orchard.Blogs, Version=, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

If I remove the reference to Orchard.Blogs completely, and remove Orchard.Blogs.dll from my module's bin, the controller runs fine.

Am I going about this dependency stuff the wrong way? Is there any other information that could help me troubleshoot this?


Name: MyModule
AntiForgery: enabled
Author: Web Station, Inc
Version: 1.0
OrchardVersion: 1.2.14
Description: Module specific to my website
        Description: My Module.
Category: Web Station
Dependencies: Orchard.Blogs
Aug 2, 2011 at 4:21 PM
Edited Aug 2, 2011 at 6:22 PM

It seems the Reference is not shown in dependencies.xml when I remove the Orchard.Blogs.dll from my module's bin.

My loaded dependency:

- <Dependency>
   <References />

Where other loaded dependencies references node looks like this:

-     <Reference>

How can I specify this reference?
Aug 2, 2011 at 6:42 PM
Edited Aug 2, 2011 at 8:44 PM

Everything works correctly when I copy my full source to the production machine.

It changes the dependency to DynamicExtensionLoader and adds the Orchard.Blogs reference.

I'm assuming Orchard digs into the csproj file for the reference and then dynamically loads it, in this case by finding the Orchard.Blogs.dll in its module folder.

Is this by design? Is there a way to add the reference from the module.txt file so I can just publish the compiled module to my production server?

Aug 2, 2011 at 8:13 PM

This is by design: you are supposed to copy the source code for your module, not its bin directory. Orchard dynamically compiles modules.

Aug 5, 2011 at 12:01 PM

does this mean, that if someone would develop a module which he wants to sell, is he always supposed to donate the source on top?

Aug 5, 2011 at 8:17 PM

For the moment at least, yes. We see giving the source as a plus. It doesn't mean that your licensing for the module needs to be open source. There are plenty of commercial components for PHP CMS for example, where not giving the source isn't even an option.

Aug 6, 2011 at 10:08 AM

yes in general i think source should be available, but! you never know where you're going. just wanted to know if there is the option, or at least if the option is easy realizable.

Aug 9, 2011 at 6:36 PM

I guess it would be a "workaround" right now, but if you provide the compiled code Orchard loads the reference as a PrecompiledExtension. Then the csproj file has to be included as well because Orchard uses it to know what references the module needs to load up.

This seems to work with my testing anyway.