Custom IPropertyProvider in custom project is not picked up by Orchard.

Topics: Core, Customizing Orchard
Jan 21, 2013 at 3:03 PM

Custom IPropertyProvider works when it's placed in project Orchard.Projections.

To keep a fine line between the Orchard codebase and my custom stuff, I'd rather move this to another project.

However, Orchard doesn't pick it up anymore (not visible in dashboard).

Any ideas? Can't find the code where Orchard searches for IPropertyProvider classes...

 

Jan 21, 2013 at 3:08 PM

Perhaps try a full rebuild of the solution and recycle the application pull. Sometimes when you make a change in your module and compile (or don't compile), an older binary version is used. Rebuilding usually resolves that.

IPropertyProvider implementations are loaded like any other dependencies via AutoFac.

Jan 21, 2013 at 4:52 PM

Is the class public ?

Jan 21, 2013 at 7:28 PM

A full rebuild does not solve the issue, nor does recycling my app pool. The class is public.

When I put the source code in Orchard.Projections, it's working. When i move the file to my project it stops working. Files are 100% identical.

I had to reference "Orchard.Projections" from my project (for IPropertyProvider) and I referenced my project in Orchard.Web. The bin folder contains the compiled dll of my project.

Even if it's loaded via AutoFac, there has to be some code that uses reflection on assemblies to search for IPropertyProvider instances (or even IDependency)?

 

Jan 21, 2013 at 7:34 PM

Did you enable the feature of your module?

You should not reference your project from Orchard.Web.

 

Jan 21, 2013 at 7:41 PM
Edited Jan 21, 2013 at 7:47 PM

I didn't create the project as an Orchard module. It is just a plain vanilla class library project, like I would do in any MVC solution. It also contains some generic stuff and some helper methods (like the one in my previous thread).

So I should make it a module then...?

Jan 21, 2013 at 10:34 PM
Edited Jan 21, 2013 at 10:35 PM

Yes, because Orchard only scans class libraries that have a valid Module.txt file. Alternatively, what you could try, is to implement an Autofac Module (a class inheriting from Module, don't know the namespace from the top of my head, probably something like Autofac.Module). Perhaps that one does get picked up without having a module manifest, but I can't be sure until you try it ;)

But I assume you are planning on writing a module since you're working in an Orchard solution, so adding the Module.txt file seems to be the right thing to do.

Jan 23, 2013 at 2:08 PM

It's working now, thanks.

I've 'converted' the project to an Orchard module and I've put it inside the module folder (wasn't the case). Life is good again :)