ITaxonomyService dependency injection security issue

Topics: Customizing Orchard, Troubleshooting
Aug 17, 2011 at 3:28 PM

Hello all,

I'm trying to utilize the TaxonomyService programmatically.

ITaxonomyService is in the controller constructor along with the other interfaces (which have no problems coming in):


public ArticleGroupAdminController(
            ITaxonomyService taxo,
            IOrchardServices services,
            IArticleGroupService articlegroupService,
            IArticleService articleService,
            IContentManager contentManager,
            ITransactionManager transactionManager,
            IArticleGroupPathConstraint articlegroupPathConstraint,
            ISiteService siteService,
            IShapeFactory shapeFactory,
            ITagService tagger) 
            _taxo = taxo;
            Services = services;
            _articlegroupService = articlegroupService;
            _articleService = articleService;
            _contentManager = contentManager;
            _transactionManager = transactionManager;
            _articlegroupPathConstraint = articlegroupPathConstraint;
            _siteService = siteService;
            brafton = new ApiContext(api_key, base_url);
            _tagger = tagger;
            T = NullLocalizer.Instance;
            Shape = shapeFactory;


I get the following server error with this setup:

Attempt by security transparent method 'NS.Articles.Controllers.ArticleGroupAdminController..ctor(Contrib.Taxonomies.Services.ITaxonomyService, Orchard.IOrchardServices, NS.Articles.Services.IArticleGroupService, NS.Articles.Services.IArticleService, Orchard.ContentManagement.IContentManager, Orchard.Data.ITransactionManager, NS.Articles.Routing.IArticleGroupPathConstraint, Orchard.Settings.ISiteService, Orchard.DisplayManagement.IShapeFactory, Orchard.Tags.Services.ITagService)' to access security critical type 'Contrib.Taxonomies.Services.ITaxonomyService' failed.

Am I going about this the wrong way or is it a permissions issue I've overlooked?

Basically, how do I set up a useable TaxonomyService instance?

Aug 17, 2011 at 6:26 PM

Your constructor seems ok. :/

More code to share ?

Aug 17, 2011 at 6:41 PM

No problem! I just hope I can share the right pieces.

These are the attributes on the Controller class

[ValidateInput(true), Admin]
public class ArticleGroupAdminController : Controller, IUpdateModel 
     private readonly ITaxonomyService _taxo;

The Taxonomy Module has not been modified in any way, it's right out of the box.

And everything goes back to normal when I remove the ITaxonomyService from the Constructor parameter list, but then..I can't use the TaxonomyService :\

What other code might be helpful to share?

Aug 17, 2011 at 7:57 PM

Are you running into this error from a new module you've created?  I ran into a similar issue and then stumbled along the same solution these folks came up with in this thread:

Not sure if this is related, but it smells similar...

Aug 17, 2011 at 9:15 PM

Awesome!! That was it, thank you.

Yes, it was coming from a custom module.

Added [assembly: SecurityTransparent] to AssemblyInfo.cs and magic.

Aug 17, 2011 at 9:31 PM

Excellent, glad to help.