0

In my class NinjectSPHttpApplication I have inherited SPHttpApplication class in order to use Ninject as IOC container. When I set global.asax to inherit from this class it throws an exception that the assembly does not allow partially trust callers, which seems quite odd. I cannot use attribute AllowPartiallyTrustedCallers since Ninject's assembly (dll) does not allow that. I have set the web trust to medium trust.

Is there any other solution then to set the web's trust to full trust? Possibly to set some IPermissions in the deploy package?

0

If you really want to go this way you must run the web application in full trust mode. BTW. SharePoint 2013 runs in full trust mode by default.

But how are you planning on deploying the modified global.asax to the SharePoint servers? Maybe you should find another composition root for your IoC. Typically you want to create base classes for web parts, user controls, feature receivers and the like that do the IoC composition. It is not nice, because it gives you multiple composition roots, but there are no real alternatives as I see it...

  • Good point with SP2013, I guess it is not such an evil to run SP in full trust mode. To avoid the multiple composition roots I have placed ninject into the inhereted class of the SPHttpApplication and I created a static Inject method which gets the application from SPCurrent. I should have access to global.asax when I deploy it so it wont be a problem. This is actually a quite supported solution as far as I read the blogs. I then inhereted the webparts and user controls and use the static method in their OnInit handler. – Santhos Nov 23 '13 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.