-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MVC 3 Medium Trust #15
Comments
It seems this requires a configuration to disable the support for the injection of ValidationAttributes. |
Thank you for the response remogloor. I see the issue has been marked as closed. Could you elaborate a little more on your statement above? Does such a configuration already exist? If so, where? Does this mean that Validation Attributes we decorate our classes with will not be supported if the class is instantiated by injection in a Medium Trust environment? |
Oh sorry. I didn't want to close this topic. There is no such configuration yet. This has to be added. After this change Validation Attributes are still supported. But injection into validation attributes is not support anymore. |
Thank you for the clarification. |
hi - any idea when a fix for this might be available? I don't want to switch to Unity to get DI working in medium trust if i can help it :) |
This is planned for the next release. I can't give you any ETA at the moment. But we are hard working towards this release. If you need it before you are still welcome to fork the sources and fix the problem yourself. If you need help with doing so I'll try to assist you. |
thanks for the response remogloor - i'll take a look at the src and see what i can do |
I've modified CreateKernel as per other info sources :
but still I get : System.Security.SecurityException was unhandled by user code It doesn't seem to have anything to do with the injection of ValidationAttributes.. Any ideas? |
The problem is caused by a workaround for a bug in the .NET framework. It should be possible to support medium trust. But defenately not without any side effect for property injection which will not work in some scenarios because of this bug. This requires a lot of additional analysis though as it is a problem deep into property reflection. (MS hasn't managed to get this working properly either since .NET 1.0) |
Use https://github.com/downloads/ninject/ninject/Ninject-2.2.1.3-release-net-4.0-mediumTrust.zip for the moment. Before you ask there won't be a nuget package for 2.2. Also configure the kernel like this: This version fixes the issue hardcoded. The final fix will be released with 2.4 where medium trust will be configurable. It's not configurable in 2.2 because this would be a large change which could have side effects. |
Would you have a version that is built with the .net 3.5 framework and MVC2 as well? |
It's not a MVC related problem, but caused by Ninject core. I havn't checked but the same fix should apply to MVC2 |
yes, but it is built with .net 4.0 references, so it won't work in a 3.5 environment...should I just download and build the latest version in Github? |
Probably you are lucky. It seems I still had a build on my machine. But I don't have the time to verify this build at the moment. It also won't get a high prio on my task list either. If this is not working then please tell me so that I can delete it again, take the MediumTrust branch and compile it yourself. https://github.com/downloads/ninject/ninject/Ninject-2.2.1.3-release-net-3.5-mediumTrust.zip |
Hi, This issue is fixed on version 3 ?? Thanks |
It was not easy to have this configurable, so there is still a medium trust build available frm google code |
We have the same problem, we are trying to use Ninject in Rackspace CloudSites environment that is a "modified" MediumTrust level, we tried in several ways being sure that the assembly is set to AllowPartialCallers and we are getting the same security / permission error message: [SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.] System.AppDomain.get_Evidence() +24 Ninject.Modules.AssemblyNameRetriever.CreateTemporaryAppDomain() +19 Ninject.Modules.AssemblyNameRetriever.GetAssemblyNames(IEnumerable1 filenames, Predicate1 filter) +50 Ninject.Modules.CompiledModuleLoaderPlugin.LoadModules(IEnumerable1 filenames) +87 Ninject.Modules.ModuleLoader.LoadModules(IEnumerable1 patterns) +379 Ninject.KernelBase.Load(IEnumerable1 filePatterns) +40 Ninject.KernelBase..ctor(IComponentContainer components, INinjectSettings settings, INinjectModule[] modules) +359 Ninject.KernelBase..ctor(INinjectModule[] modules) +92 Ninject.StandardKernel..ctor(INinjectModule[] modules) +5 TPS.Framework.NInject.NinjectIocContainer..ctor(INinjectModule[] modules) in NinjectIocContainer.cs:22 WebServices.Global.CreateKernel() in Global.asax.cs:22 Ninject.Web.Common.Bootstrapper.Initialize(Func1 createKernelCallback) +16 Ninject.Web.Common.NinjectHttpApplication.Application_Start() +102 Any idea or suggestion? Thanks in advance, Andres Watson ([email protected]) |
Andreswatson, did you get this working on your hosting environment? I'm having the same issue with Winhost.com hosting an ASP.NET 4.5 application using Ninject 3.0.1.10 and Ninject.MVC3. Works fine locally, then on hosting environment I get this error: |
Have you tried using a mudium trust build? |
Hi Remogloor, thanks for the fast response! I uploaded the DLL to my project, but still get the security error: Any ideas? |
I got it to work... I managed to set my app to full trust in the web.config: I was trying to use this: Which didn't work. |
Hi. It was impossible for us to make it work. It is obvious that no one has Andrés Watson @ Mobile
|
CARLIN. Does it worked? Andrés Watson @ Mobile
|
I managed to get it working on Winhost.com, but that was because it is using full trust... I managed to set my app to sue full trust by using the correct settings in the web.config, when I tried copying up the medium trust DLL that didn't work. |
We couldn't make it work in Rackspace. We had to set a dedicated server to It would be great to know if anyone had the chance to use the medium trust Cheers. Andrés Watson @ Mobile
|
Hi. Has anyone managed to make this work using the partial trust assemblies? I downloaded the medium trust assemblies and also passed "LoadExtensions = false, UseReflectionBasedInjection = true" but still got the security exception. |
Please try the .NET 4.5 Medium trust build from the build server. I don't https://teamcity.bbv.ch/viewLog.html?buildId=987&tab=artifacts&buildTypeId=bt7 2012/12/11 nvivo64 [email protected]
|
Hi, I have been able to use the 4.0 medium trust assemblies from the Google Code download page. Ended up that some of my problems were about the project not being prepared to run in Medium Trust, as I have never had to use that before. I had to do some setup to make it to work, so I'm posting here what I had to do. My project is an ASP.NET MVC 4 with .NET 4.0.
var kernel = new StandardKernel(new NinjectSettings() { LoadExtensions = false } ); and then added: kernel.Load(new Ninject.Web.Mvc.MvcModule()); This second line is important. As we tell it to not load extensions automatically, you need to load at least the MvcModule that would be loaded automatically before. It sets up the basic bindings for Ninject to work, otherwise it won't be able to create anything. The next 2 steps are not about ninject, but about Medium Trust. As I had to change so the website would work, so here it is:
Sorry about the long post here, but hope it helps people having the same problem. Could be an entry in the wiki explaining that. Thanks! |
Where are you hosting this Meddium Trust solution? *Andrés Watson Phone: +54 (11) 4780.3337 | Skype: andreswatson On Tue, Dec 11, 2012 at 10:01 AM, nvivo64 [email protected] wrote:
|
Having an issue getting Ninject.Web.Mvc to work in Medium Trust. "UseReflectionBasedInjection" is set to true as a parameter during the creation of the kernel, but am getting the following error:
System.Security.SecurityException
Attempt by method 'Ninject.Web.Mvc.Validation.NinjectDataAnnotationsModelValidatorProvider.GetValidators(System Web.Mvc.ModelMetadata, System.Web.Mvc.ControllerContext, System.Collections.Generic.IEnumerable`1)' to access method 'System.Web.Mvc.DataAnnotationsModelValidator.get_Attribute()' failed.
The text was updated successfully, but these errors were encountered: