Business Objects Project references from custom module are not recognized

Feb 1, 2011 at 12:29 AM

Not sure what i must have been missing in this case, but business object (BO) projects that i refer in my module arent available at run time and that end up breaking my views (Views are strongly typed to the ViewModel classes that sits in the BO project). If i add a reference to my BO project from Orchard.Web project everything works fine. Apparently the dependencies for the custom modules arent copied over?

Feb 1, 2011 at 12:31 AM

Yes they are, if they are correctly referenced by the project.

Feb 1, 2011 at 12:35 AM

Shouldnt the compilation break if they are not correctly referenced? Obviously BO is accessed in the Controller code as well! Anything specific that you can think of that i must check?


Feb 1, 2011 at 1:47 AM

Ah! I think you found a bug. When we compile .csproj files, we add references to the libraries in the "bin" folder of the module. However, we don't when we compile views (more exactly, we don't notify the razor view engine): we only notify about module references (not binary only references). Would you mind creating a work item for this?

I think a workaround might be to add the BO assembly in the "<compilation/assemblies>" section of the web.config of your Module (it doesn't need to be in the main web.config of the app). If that works, it would still allow your module to be self-contained...

Feb 1, 2011 at 1:56 AM

Just to be clear: you should not need to change the web.config for module references (e.g. if your module references Orchard.Users for example). You currently only need to do this if your module references a "non-orchard" assembly.

Feb 6, 2011 at 7:43 PM

juzfun, did the workaround end up working for you?

Feb 7, 2011 at 1:20 AM

@rpaquay, Thanks for checking :)

i remember trying adding my assemblies to assemblies section in the web.config, both under system.web and razor view section, but it didnt work for me then. i am making another module from scratch and see if that works. i guess its not just about the views that loses the biz objects even DI doesnt work when the objects belong to the custom BO projects (i believe its because DI Framework doesnt yet know that such a type exists because they are not copied over to the root bin and autofac cant find and inject them)