Support for postgre database in Medium Level Trust on IIS

8 posts, 0 answers
  1. willy
    willy avatar
    5 posts
    Member since:
    Aug 2011

    Posted 26 Aug 2011 Link to this post

    Hi.

    Does Open Access ORM work on IIS with Medium Level Trust, using Postgre Database(npgsql driver) ?
    If there is a way, How is it?

    Thanks.
  2. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 29 Aug 2011 Link to this post

    Hello Willy,
    As far as I know there is no medium trust problem with OpenAccess. Which errors are you getting and how does your setup look like?

    All the best,
    Jan Blessenohl
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

  3. DevCraft banner
  4. willy
    willy avatar
    5 posts
    Member since:
    Aug 2011

    Posted 29 Aug 2011 Link to this post

    Hi Jan,

    I tried again, and I have the error:

    Sin conexion.
     Descripcion del error: Required security permission not given for the database driver used. Telerik.OpenAccess.RT.sql.SQLException: Required security permission not given for the database driver used. ---> System.Security.SecurityException: That assembly does not allow partially trusted callers.
       at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(RuntimeAssembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed)
       at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, RuntimeMethodHandleInternal method, RuntimeType parent, UInt32 invocationFlags)
       at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, IRuntimeMethodInfo method, RuntimeType parent, UInt32 invocationFlags)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
       at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
       at OpenAccessRuntime.ReflectionUtils.SetInstanceProperty(Object obj, String name, Object val)
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PostgreSqlFactory.MapConnectionString(ConnectionString conString)
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PostgreSqlFactory.CreateConnection(ConnectionString conString, String& id)
       --- End of inner exception stack trace ---
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.DBDriver.connect(ConnectionString connectionString, IDictionary driverProps)
       at OpenAccessRuntime.Relational.sql.SqlDriver.InitializeFor(ConnectionString connectionString, Boolean noConnect, PropertySet props, Driver& driver, Connection& conn)
    Metodo que produce la excepcion: System.Collections.Generic.List`1[GantNube.BE.Usuario] getConnection()
    Pila de errores:    at GanttNube.BL.BLTareas.getConnection() in D:\PROYECTOS\SIMBIOSYS\NUBE.GANTT\04.DES\DES\GE.WS\GanttNube.BL\BLTareas.cs:line 38
       at GanttNube.WS.Service.getPruebaConexion() in D:\PROYECTOS\SIMBIOSYS\NUBE.GANTT\04.DES\DES\GE.WS\GanttNube.WS\Service.asmx.cs:line 29

    And in the "Model Settings" I selected "Medium Trust" and mi IIS server has a "Medium Level Trust", but when I publish it doesn't work.

    So I have Telerik version:
    Telerik_OpenAccess_ORM_Free_Edition_2011_2_713_SDK
    Telerik_OpenAccess_ORM_Free_Edition_2011_2_713

    Regards
  5. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 29 Aug 2011 Link to this post

    Hello Willy,
    It looks like they have changed that with the latest version of the driver. Maybe the one that we ship is too old. Please download the latest version from here. As I can see it, it should work.

    All the best,
    Jan Blessenohl
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

  6. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 29 Aug 2011 Link to this post

    Hi Willy,
    I forgot to mention that you have to add the provider fatcory entry to your web.config to redirect to the new version.

    3.4 Using Npgsql with ProviderFactory

    Npgsql can be used with Provider Factory pattern which allows you to write code which is independent of database you are using.

    In order to do that, you have to use the following configuration:

    <?xml version="1.0" encoding="iso-8859-1" ?>
      <configuration>
        <system.data>
          <DbProviderFactories>
            <add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.0.11.91, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />
          </DbProviderFactories>
        </system.data>
      </configuration>

    This configuration can be put inside the global machine.config file or in the application specific .config file.

    You have to replace the version with the one you are downloading.

    Kind regards,
    Jan Blessenohl
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

  7. willy
    willy avatar
    5 posts
    Member since:
    Aug 2011

    Posted 29 Aug 2011 Link to this post

    Hi Jan,
    I  added the provider factory and download npgsql versions, but I had some errors:
    - When I published with Npgsql2.0.11.91, I had the same error than http://www.telerik.com/community/forums/orm/databases/postgresql-error.aspx
    but Ady, answered :

    " This is a problem with the latest version of the Npgsql driver - 2.0.11.91. This version introduced a breaking change where the type of the NpgsqlConnectionStringBuilder.Password property was changed from 'string' to 'Byte[]'. This has been fixed by the community and a newer version is available, although it still is a preview version. "

    And She suggested: 

    "You can upgrade to this preview version or downgrade to version 2.0.10.0 .Ensure that you have only 1 version installed."

    But if I downgrade the pgsql version (different from 2.0.11.0.) the problem about security level persists, like bellow image:

    Sin conexion.
     Descripcion del error: Database driver installation problem: Cannot use factory for postgresql. Inheritance security rules violated while overriding member: 'Npgsql.NpgsqlException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden. Telerik.OpenAccess.RT.Adonet2Generic.Impl.DBDriverException: Database driver installation problem: Cannot use factory for postgresql. Inheritance security rules violated while overriding member: 'Npgsql.NpgsqlException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden. ---> System.TypeLoadException: Inheritance security rules violated while overriding member: 'Npgsql.NpgsqlException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
       at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type)
       at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
       at System.Reflection.Assembly.GetType(String name, Boolean throwOnError)
       at OpenAccessRuntime.ReflectionUtils.Load(DbProviderFactory factory, String name)
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PostgreSqlFactory.AssureLoaded(DbProviderFactory tmp)
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PostgreSqlFactory..ctor(DbProviderFactory f)
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.DBDriver.GetFactoryByName(String backend, DbProviderFactory factory)
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.DBDriver.GetFactory(ConnectionString cs, Boolean err)
       --- End of inner exception stack trace ---
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.DBDriver.GetFactory(ConnectionString cs, Boolean err)
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.DBDriver.connect(ConnectionString connectionString, IDictionary driverProps)
       at OpenAccessRuntime.Relational.sql.SqlDriver.InitializeFor(ConnectionString connectionString, Boolean noConnect, PropertySet props, Driver& driver, Connection& conn)
    Metodo que produce la excepcion: System.Collections.Generic.List`1[GantNube.BE.Usuario] getConnection()
    Pila de errores:    at GanttNube.BL.BLTareas.getConnection() in D:\PROYECTOS\SIMBIOSYS\NUBE.GANTT\04.DES\DES\GE.WS\GanttNube.BL\BLTareas.cs:line 38
       at GanttNube.WS.Service.getPruebaConexion() in D:\PROYECTOS\SIMBIOSYS\NUBE.GANTT\04.DES\DES\GE.WS\GanttNube.WS\Service.asmx.cs:line 29

    So do you know if Npgsql comunity fix this error?

    Kind regards,
  8. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 30 Aug 2011 Link to this post

    Hi Willy,
    Sorry for that, looks like the only chance to get medium trust working is to compile the 2.0.11 version by yourself. You can download the 2.0.11 and 2.0.11.91 source packages, copy the 
    Npgsql2\src\Npgsql\AssemblyInfo.cs
    File from the 2.0.11.91 to the 2.0.11 version and build the 2.0.11 version. That should fix your problem.

    Best wishes,
    Jan Blessenohl
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

  9. willy
    willy avatar
    5 posts
    Member since:
    Aug 2011

    Posted 07 Sep 2011 Link to this post

    Hi Jan.

    It worked.

    Thanks a lot.
Back to Top
DevCraft banner