Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7871851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:02:13+00:00 2026-06-03T02:02:13+00:00

A friend made a ASP.NET website work with NHibernate locally on his computer, and

  • 0

A friend made a ASP.NET website work with NHibernate locally on his computer, and on my computer after I downloaded it from a SVN repository. However, we’re trying to host it on a shared hosting environment with Medium Trust Level. The server gives the following exception (partial stacktrace):

[SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
   System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +31
   System.Security.CodeAccessPermission.Demand() +46
   System.Reflection.Emit.DynamicMethod.PerformSecurityCheck(Type owner, StackCrawlMark& stackMark, Boolean skipVisibility) +166
   System.Reflection.Emit.DynamicMethod..ctor(String name, Type returnType, Type[] parameterTypes, Type owner, Boolean skipVisibility) +40
   NHibernate.Bytecode.Lightweight.ReflectionOptimizer.CreateDynamicMethod(Type returnType, Type[] argumentTypes) in ReflectionOptimizer.cs:104

Something to do with reflection. On NHforge.org is a guide that tells to switch off the Reflection Optimiser. I can’t find how to do it but I suspect you simply can’t do it at all in an ASP.NET Website in VS2010. Someone else on SO suggested to convert it to an ASP.NET Web application first, where you have more control on the assembly references.

The problem is that the deadline for the website (it’s a school project) is already friday of next week. We haven’t learnt any kind of ORM but we were hoping it could save us a lot of time. I would like to pose 3 questions:

  1. Given the exception and the fact that it’s a shared hosting with medium trust, will we possibly get NHibernate working in a decent amount of time?

  2. How do we convert our web site to a web application?

  3. What further steps do we need to take?

I know it’s not really allowed to ask more than one question at a time but these questions are very related and I have a feeling that there is a single answer to all of them.

Any help is appreciated. If you need the full stacktrace I’ll post it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:02:14+00:00Added an answer on June 3, 2026 at 2:02 am

    See this blog post and also this one. I needed to use NH3.2 on Rackspace cloud which uses Medium Trust. All you need to do is run this Nuget command and it should download the correct assemblies (you may need to remove your existing NH dll’s first).

    PM> Install-Package NHibernate.DependencyInjection
    

    The nuget packagage that can be found here.

    Then put this code in your app:-

    protected void Application_Start() {  
      Initializer.RegisterBytecodeProvider();  
      ...  
      Rest of configuration code here  
    }  
    

    It looks like Randy has updated this to work with NH3.3.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a website for a friend and he uploads a lot of pictures,
A friend and myself are sharing my computer. I've made pushes to GitHub using
I took a very heavy website of my friend and made a few changes
Recently my friend gave me a project which is made of vb.net and sql
Recently, I made a new friend. His name is _expand , and we've had
I made a photography website for a friend and theyve asked me if its
I made this site for my friend and I uploaded it to an Amazon
So I have made a simple site for a friend using codeigniter and grocery
A friend recently had the occasion for a legal name change, which made me
my friend has made a really helpful class library which I use all the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.