These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Exception with medium trust
PostPosted: Wed Mar 07, 2007 3:14 pm 
Newbie

Joined: Tue Feb 20, 2007 12:04 pm
Posts: 16
I'm running into a problem running my application under a GoDaddy hosted account (yes, I've read all of the threads re: medium trust), and I believe that I've configured everything accordingly as would be required to run NHibernate under a medium trust environment.

However, I'm still getting an exception that I cannot seem to figure out. Here's my web.config
Code:
<configuration>
  <configSections>
    <section name="nhibernate"
             type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"
             requirePermission="false" /><!-- Important under Medium Trust -->
   <section name="log4net"
               type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"
               requirePermission="false" /><!-- Important under Medium Trust -->

  </configSections>

  <nhibernate>
    <add
      key="hibernate.connection.provider"
      value="NHibernate.Connection.DriverConnectionProvider"
    />
    <add
      key="hibernate.dialect"
      value="NHibernate.Dialect.MsSql2000Dialect"
    />
    <add
      key="hibernate.connection.driver_class"
      value="NHibernate.Driver.SqlClientDriver"
    />
    <add
  key="hibernate.adonet.batch_size"
  value="10"
    />
    <add
      key="hibernate.connection.connection_string"
      value="Data Source=whsql-v12.prod.mesa1.secureserver.net;Initial Catalog=DB_125388;Persist Security Info=True;User ID=brightharbour;Password=Merlin74;"
    />

<add key="hibernate.bytecode.provider" value="null" /><!-- Important under Medium Trust -->
 
</nhibernate>


  <log4net>
    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="BHNet.log"/>
      <appendToFile value="true"/>
      <datePattern value="yyyyMMdd"/>
      <rollingStyle value="Date"/>
      <!--
         <filter type="log4net.Filter.LevelRangeFilter">
            <acceptOnMatch value="true" />
            <levelMin value="INFO" />
            <levelMax value="FATAL" />
         </filter>
         -->
      <layout type="log4net.Layout.PatternLayout">
        <!--
            <conversionPattern value="%d [%t] %-5p %c [%x] - %m%n"/>
            -->
        <conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n"/>
      </layout>
    </appender>
    <root>
      <level value="DEBUG"/>
      <!--
         <appender-ref ref="ConsoleAppender"/>
         <appender-ref ref="SmtpAppender"/>
      -->
      <appender-ref ref="RollingLogFileAppender"/>
    </root>
  </log4net>
  <appSettings>
    <add key="bh.config.path" value="bh.config"/>
  </appSettings>

  <connectionStrings/>

  <system.web>


    <httpHandlers>
      <add verb="*" path="MediaService.aspx" type="com.brightharbour.net.MediaService, BH.Net" />
    </httpHandlers>

    <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        -->
    <compilation debug="true" />
    <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
    <authentication mode="Windows" />
<!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.
-->
        <customErrors mode="Off" />

  </system.web>
</configuration>



And here's where I'm getting the exception in some code:
Code:
                NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
                cfg.AddAssembly(Assembly.GetExecutingAssembly());
                               
                ISessionFactory factory = cfg.BuildSessionFactory();
                ISession session = factory.OpenSession();<-- exception occurs here


Here's the actual exception (which I catch and return as XML):
Code:
<doAddUserResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:com.brightharbour.schema">
  <Result>Failure</Result>
  <Error>
    <DetailedMessage>Attempt to access the method failed..  Data:  System.Collections.ListDictionaryInternal.  Help:  .  TargetSite:  System.Object CreateInstance(System.RuntimeType, Boolean, Boolean, Boolean ByRef, System.RuntimeMethodHandle ByRef, Boolean ByRef)</DetailedMessage>
    <ErrorSource>mscorlib</ErrorSource>
    <Trace>   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean&amp; canBeCached, RuntimeMethodHandle&amp; ctor, Boolean&amp; bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
   at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at NHibernate.Impl.SqlClientSqlCommandSet..ctor()
   at NHibernate.Impl.SqlClientBatchingBatcher..ctor(ConnectionManager connectionManager)
   at NHibernate.Driver.SqlClientDriver.CreateBatcher(ConnectionManager connectionManager)
   at NHibernate.Impl.SessionImpl.InitTransientState()
   at NHibernate.Impl.SessionImpl..ctor(IDbConnection connection, SessionFactoryImpl factory, Boolean autoClose, Int64 timestamp, IInterceptor interceptor, ConnectionReleaseMode connectionReleaseMode)
   at NHibernate.Impl.SessionFactoryImpl.OpenSession(IInterceptor interceptor)
   at NHibernate.Impl.SessionFactoryImpl.OpenSession()
   at com.brightharbour.service.media.doAddUserImpl.ProcessMediaRequest(Hashtable parms) in C:\Inetpub\wwwroot\Brightharbour\BH.Net\BH.Service\com\brightharbour\service\media\doAddUserImpl.cs:line 42</Trace>
  </Error>
</doAddUserResponse>


As I said, I've read a ton of stuff here re: medium trust, but cannot seem to figure this one out.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 07, 2007 3:26 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You can't use update batching under medium trust. Don't set hibernate.adonet.batch_size.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 07, 2007 3:52 pm 
Newbie

Joined: Tue Feb 20, 2007 12:04 pm
Posts: 16
Brilliant, sergey! That solved the problem, and everything works perfectly fine now.

Many thanks!!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.