How does Orchard resolve references in modules?
Asked Answered
A

1

7

The documentation (here and here) is notably lacking information on how references in modules are resolved:

References Resolution

(TODO: Explain how Orchard figures out references by looking at the "References" section of the csproj file as well as looking at additional assembly binaries dropped in each module "bin" directory)

Unfortunately, this is exactly the information that I need. I have created a custom module that has a reference to a custom-built, in-house DLL. When I try to use a class from this DLL, I get the following Exception:

Could not load type 'Custom.MyClass' from assembly 'Custom, Version=[version], Culture=[culture], PublicKeyToken=[token]'.

So, my question is thus: What does Orchard do with module references, and is there anything special I need to do to have Orchard pick up my module's references?

EDIT: Looks like some better information can be found in this blog post and its comments. However, my custom assembly already exists in src\Orchard.Web\App_Data\Dependencies, and I'm still getting the error.

EDIT2: We have a copy of the custom DLL in the lib folder, so I tried referencing that one instead (as we have another module that does so successfully), but still no change.

EDIT3:: In reference to the previous two edits, it's not copying from the lib folder to the App_Data\Dependencies folder. I just added a new DLL to the lib folder and referenced it, and it didn't appear in the Dependencies folder. I think the current Custom.dll isn't replacing the one that's there, which is why I'm getting the error I am. But why isn't Orchard copying into the Dependencies folder?

Angeles answered 3/5, 2013 at 19:23 Comment(0)
L
1

In order to have Orchard to use your custom module you need to have it on path: your_web_application_path/Modules/your_custom_module, we are using sym links to achieve that.

Then your main module (web application) should see your custom module. If you are adding new module to existing orchard app, you probably need to enable it by hand from admin panel/modules menu. For new installations you could add feature enable directive to your recipe and add dependency to main module.txt file (assuming you want your module always on).

Another trouble shooting tips:

  • make sure your module build path is set to bin/ folder (not some bin/debug etc.)
  • make sure your module is really an orchard module (have module.txt file) and is seen in admin panel/modules
  • make sure it is enabled, new modules are by default disabled
  • make sure referenced libraries are referenced from static folder I mean not from someting like bin which is clean up during rebuild
Ludly answered 18/5, 2013 at 10:12 Comment(1)
The module shows up and works just fine once we move the referenced DLLs (which are in a static folder) to the Dependencies folder. (The module is in the right place - I created it using the orchard command line.)Angeles

© 2022 - 2024 — McMap. All rights reserved.