Fluent Config, Medium Trust, Metadata.Inflector

7 posts, 0 answers
  1. Bitsmith
    Bitsmith avatar
    6 posts
    Member since:
    Dec 2005

    Posted 29 Oct 2011 Link to this post

    Hi,

    I'm using OA with fluent mapping - which is a nice feature.   It works great in dev mode.

    But I'm running into a security issue when I run it in a medium trust environment.

    I have no need for the features that inflection provides (which appears to be the source of the problem).  Is there a possible work-around for this?

    --------------------------------
    The exception and stack traces are below:

    --- The error showing on the view...:

    [SecurityException: Request for the permission of type 'System.Security.Permissions.RegistryPermission, 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
       Microsoft.Win32.RegistryKey.CheckPermission(RegistryInternalCheck check, String item, Boolean subKeyWritable, RegistryKeyPermissionCheck subKeyCheck) +9629534
       Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) +70
       Microsoft.Win32.RegistryKey.OpenSubKey(String name) +6
       Telerik.OpenAccess.Metadata.Inflector.GetInstallDir() +135
       Telerik.OpenAccess.Metadata.Inflector..cctor() +2465
     


    --- Inner exception when debugging...:
    Exception: The type initializer for 'Telerik.OpenAccess.Metadata.Inflector' threw an exception.

    Stack Trace:
       at Telerik.OpenAccess.Metadata.Inflector.Camelize(String lowercaseAndUnderscoredWord)
       at Telerik.OpenAccess.Metadata.DefaultNamingStrategy.ApplyNamingRules(NamingRules rules, String newPropertyName)
       at Telerik.OpenAccess.Metadata.Fluent.PropertyConfiguration.GetFieldName()
       at Telerik.OpenAccess.Metadata.Fluent.PropertyConfiguration.get_FieldName()
       at Telerik.OpenAccess.Metadata.Fluent.PropertyConfiguration.GetMemberType()
       at Telerik.OpenAccess.Metadata.Fluent.PropertyConfiguration.AddConceptualItem(FluentMetadataSource fluentMappingSource, MetaPersistentType persistentType)
       at Telerik.OpenAccess.Metadata.Fluent.MappingConfiguration.AddSlaveAssociationMapping(FluentMetadataSource fluentMappingSource, MetadataContainer metadataContainer)
       at Telerik.OpenAccess.Metadata.Fluent.FluentMetadataSource.CreateModel()
       at Telerik.OpenAccess.Metadata.Fluent.FluentMetadataSource.GetModelCore(MetadataContainer model)
       at Telerik.OpenAccess.Metadata.MetadataSource.GetModel()
       at Telerik.OpenAccess.OpenAccessContextBase.GetMetadataContainerFromSource(MetadataSource metadataSource)
       at Telerik.OpenAccess.OpenAccessContextBase..ctor(String connectionString, BackendConfiguration backendConfiguration, MetadataSource metadataSource, Assembly callingAssembly)
       at Telerik.OpenAccess.OpenAccessContext..ctor(String connectionString, BackendConfiguration backendConfiguration, MetadataSource metadataSource)
  2. Serge
    Admin
    Serge avatar
    375 posts

    Posted 02 Nov 2011 Link to this post

    Hi Bitsmith,

     It looks as a bug on our side, we will continue digging in and most probably fix this issue for the upcoming Q3 release. However for the time being there is an easy solution to your problem and that would be to just explicitly specify the field names for all properties. (You can do this by using syntax much like configuration.HasProperty(...).HasFieldName(string)). Another solution would be to switch to auto properties.

    Any of these solution would lead to the Inflector not be used because there will be no need to calculate the field name. 

    I hope this is helpful, please do find your Telerik point updated for reporting this issue.

    Best wishes,
    Serge
    the Telerik team
    Want to use Telerik OpenAccess with SQL Azure? Download the trial version today. 
  3. DevCraft banner
  4. Bitsmith
    Bitsmith avatar
    6 posts
    Member since:
    Dec 2005

    Posted 12 Nov 2011 Link to this post

    Thanks for your response.

    How would I "switch to Auto Properties"?
    It's not easy to find in the documentation.
  5. Serge
    Admin
    Serge avatar
    375 posts

    Posted 14 Nov 2011 Link to this post

    Hi Bitsmith,

     I am sorry for not making myself clear, by auto-properties I meant auto-implemented properties. When those are used the field name is not calculated and can be inferred directly thus working around the current issue. Of course it will require a bit of coding on your side, but it should be pretty straightforward and easy.

    I hope this is helpful. Please keep in mind that the fix for your issue will be available shortly as we will be shipping out the new Q3 release by the end of the week. 

    Greetings,
    Serge
    the Telerik team
    Want to use Telerik OpenAccess with SQL Azure? Download the trial version today. 
  6. Bitsmith
    Bitsmith avatar
    6 posts
    Member since:
    Dec 2005

    Posted 14 Nov 2011 Link to this post

    The original error posted was a scenario where all the class's properties had used the auto-implement approach you referenced.
    So I don't see that as a fix.

    I also tried refactoring the class properties to have backing fields and made the appropriate additions in the metadatasource... still running into issues.

    Looking forward to the fix in the Q3 release.

    Thank you for your help so far.
  7. Serge
    Admin
    Serge avatar
    375 posts

    Posted 17 Nov 2011 Link to this post

    Hi Bitsmith,

     Are you sure that all of the properties were actually auto-properties, from the call stack I can see that you get the exception in a method that is only called if there are properties that are fully defined. Maybe there was a single property that was fully defined that lead to this behaviour. 

    I am writing to let you know that yesterday we published the Q3 release of OpenAccess that contains the fix for your issue. 

    Do not hesitate to let us know if you face further trouble.

    Kind regards,
    Serge
    the Telerik team
    Want to use Telerik OpenAccess with SQL Azure? Download the trial version today. 
  8. Bitsmith
    Bitsmith avatar
    6 posts
    Member since:
    Dec 2005

    Posted 18 Nov 2011 Link to this post

    Ah.
    There is a possibility that one or a few properties across the many classes were not declared properly.

    I've tried it with the latest update and it works.

    Thanks a lot!!
Back to Top
DevCraft banner