Pregunta

I am using (from Nuget packages) Ninject 2.2 and Fluent NHibernate 1.3 (NHibernate v3.2 under the hood) and I've hit a brick wall.

I am using Fluent config to point to my database, mappings etc:

var fluentConfig = Fluently.Configure()
    (MsSqlConfiguration.MsSql2008.DoNot.UseReflectionOptimizer()
    .ConnectionString(c => c.FromConnectionStringWithKey("ExampleDB")))
    .Mappings(m => m.FluentMappings.AddFromAssemblyOf<ExampleMap>()
    .Conventions.Add(FluentNHibernate.Conventions.Helpers.DefaultLazy.Never()))
    .ExposeConfiguration(x => x
                            .SetProperty("current_session_context_class", "web"))
    .ExposeConfiguration(BuildSchema);

The code works beautify on my local box, until I set < trust level="Medium" /> to mirror my hosting provider and then it starts to barf.

The problem line is the 2nd one in this code block

Bind<Configuration>().ToConstant(fluentConfig.BuildConfiguration());
Bind<ISessionFactory>().ToConstant(fluentConfig.BuildSessionFactory());
Bind<ISession>().ToMethod(x => GetRequestSession(x));

The exception I recieve: "...Request for the permission of type 'System.Security.Permissions.ReflectionPermission....failed"

Does anyone have any suggestions? My investigations thus far are turning up nothing but either out of date info based on older versions of Ninject and NHibernate or solutions that involve decompiling X to disengage Y...which I'd rather not do!

¿Fue útil?

Solución

Use the medium trust build instead of the version from NuGet: https://github.com/ninject/ninject/downloads

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top