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.  [ 23 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: That assembly does not allow partially trusted callers
PostPosted: Thu Aug 17, 2006 11:27 am 
Regular
Regular

Joined: Fri Nov 04, 2005 12:37 pm
Posts: 81
I am attempting to use the very good pattern online lined here for my web app:

http://www.codeproject.com/aspnet/NHibe ... ctices.asp

Its not rocket sicence just outlines a few good pratices for using Nibernate and generic to create a Data Access layer for asp 2.0.

The code is logically tiered and seperated off into different class libraries, and the following error is being thrown by my web tier:

Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers.

on the line:
PersonalDetail person = personalDetailDao.GetById(1398318,false);

Iv added [assembly: AllowPartiallyTrustedCallers()] to both the core and data tiers assemblies but this still does not fix the problem. Why not? and why did the author of the above tutorial not have the same problem? When i look at his source code he has not even need to grant trust in the assemblies.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 5:29 am 
Regular
Regular

Joined: Fri Nov 04, 2005 12:37 pm
Posts: 81
Any help with this chaps?

I have even got the iesi.collections source and recompiled it with AllowPartiallyTrustedCallers, but still no joy


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 6:17 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
bosh wrote:
Any help with this chaps?

I have even got the iesi.collections source and recompiled it with AllowPartiallyTrustedCallers, but still no joy


See http://forum.hibernate.org/viewtopic.php?t=961912 for more information about medium trust and NHibernate

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 6:53 am 
Regular
Regular

Joined: Fri Nov 04, 2005 12:37 pm
Posts: 81
Thanks gert, i did read that, i was hoping that this didnt apply to me, because i am just trying to get this working on my local IIS server not on a hosted enviroment, also im using 1.0.2 not 1.2.

This all seems abit scary and messy to me having to take everything apart and change the trust settings. Cant this all be fixed by some incremental release of nHibernate.

Why does this happen with asp 2.0 but not 1.1?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 9:39 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
bosh wrote:
Thanks gert, i did read that, i was hoping that this didnt apply to me, because i am just trying to get this working on my local IIS server not on a hosted enviroment, also im using 1.0.2 not 1.2.

So, if it is Your own server, You can change the trust level on ASP applications... And I see no reasons why previous NHibernate versions should behave better than later ones.

bosh wrote:
This all seems abit scary and messy to me having to take everything apart and change the trust settings. Cant this all be fixed by some incremental release of nHibernate.

Maybe. AFAIK, something is changed in SVN of NHibernate... I do not know if it works with medium trust, but You could try out the latest source...

bosh wrote:
Why does this happen with asp 2.0 but not 1.1?

Because asp 2.0 did change the default trust level?

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 6:13 am 
Regular
Regular

Joined: Fri Nov 04, 2005 12:37 pm
Posts: 81
Gert I just throught 1.0.2 might be more stable etc as 1.2 is an Alpha.


Iv checked out the SVN version of nHibenate from the trunk with the hope that the trust changes made by sergy will help......but i cant get the thing to build, it claims it cannot find AssemblyInfo.cs.

Can any one help with this? All i really need is the compiled dlls


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 6:24 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
bosh wrote:
Gert I just throught 1.0.2 might be more stable etc as 1.2 is an Alpha.


Iv checked out the SVN version of nHibenate from the trunk with the hope that the trust changes made by sergy will help......but i cant get the thing to build, it claims it cannot find AssemblyInfo.cs.

Can any one help with this? All i really need is the compiled dlls


Use NAnt to build, it generates those files.

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 7:30 am 
Regular
Regular

Joined: Fri Nov 04, 2005 12:37 pm
Posts: 81
Gert you legend!!! Built Nhibernate with NAnt and i think that has done the trick.....maybe...... i now have a different error

Code:
System.IO.FileLoadException: Could not load file or assembly 'NHibernate, Version=1.0.2.0, Culture=neutral, PublicKeyToken=154fdcb44c4484fc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


Any idea?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 7:36 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
bosh wrote:
Gert you legend!!! Built Nhibernate with NAnt and i think that has done the trick.....maybe...... i now have a different error

Code:
System.IO.FileLoadException: Could not load file or assembly 'NHibernate, Version=1.0.2.0, Culture=neutral, PublicKeyToken=154fdcb44c4484fc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


Any idea?


How is the reference in You project defined? Is it Specific version=true? If yes, change it to false.

Edit: You might need to set it false for related assemblis (like IEsi.Collection) also.

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 7:49 am 
Regular
Regular

Joined: Fri Nov 04, 2005 12:37 pm
Posts: 81
Its referanced in my web and data tiers and both are version 1.2.0.1001. Iv changed the data tier to Specific version=false and there isnt a provision to change this in the web tier.

The problem still occurs.

Iv also search my computer and there are no version 1.0.2.0 dlls on my machine


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 7:59 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
bosh wrote:
Its referanced in my web and data tiers and both are version 1.2.0.1001. Iv changed the data tier to Specific version=false and there isnt a provision to change this in the web tier.

The problem still occurs.

Iv also search my computer and there are no version 1.0.2.0 dlls on my machine


VS ways are mysterious... Maybe helps if You make "Rebuild" of Your solution. Otherwise, try to wipe out all bin and obj subfolders inside solution folder... Well, with Web project /bin folder be a little bit more careful, just delete all assemblies You would update...

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 9:08 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
The problem may be that your project (or some library it uses) is referencing a signed version of NHibernate.dll and the version it finds is not signed or signed using a different key.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 11:22 am 
Regular
Regular

Joined: Fri Nov 04, 2005 12:37 pm
Posts: 81
Seem to get it working by following Gerts advice plus clearing all my dlls and recompiling everything. Thanks for the kind help gert.


I now get this error:

Quote:
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.


I assume its a side effect of me using this config section, that was for nhibernate 1.0.2?

Code:
<configSections>
    <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.1.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
  </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.connection.connection_string"
         value="Data Source=TACHYON;Initial Catalog=Alumni;Integrated Security=SSPI" />
    <add key="hibernate.connection.isolation" value="ReadCommitted" />
  </nhibernate>
  <system.web>
    <httpModules>
      <add name="SessionModule" type="AlumniBridge.Web.SessionModule" />
    </httpModules>
  </system.web>


How do i adjust this? If this is even what is causing this problem. What is the version of System.Configuration. and is PublicKeyToken?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 7:10 am 
Regular
Regular

Joined: Fri Nov 04, 2005 12:37 pm
Posts: 81
Can anyone help with this...i just want to start using good old Hiberate...all this problem work around\config stuff is killing me.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 8:46 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
First, the type name <section name="nhibernate" /> looks wrong - if you are using .NET 2, it should be type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" - you can use Reflector to determine full names of assemblies.

Second, the error seems to indicate that your application does not in fact have the permission to read its configuration. I think you have to adjust your ASP.NET permission settings to allow this, but maybe it's just a side effect of the first error.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 23 posts ]  Go to page 1, 2  Next

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.