This is a migrated thread and some comments may be shown as answers.

Fluent Config, Medium Trust, Metadata.Inflector

6 Answers 75 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bitsmith
Top achievements
Rank 1
Bitsmith asked on 29 Oct 2011, 08:12 AM
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)

6 Answers, 1 is accepted

Sort by
0
Serge
Telerik team
answered on 02 Nov 2011, 02:39 PM
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. 
0
Bitsmith
Top achievements
Rank 1
answered on 12 Nov 2011, 07:14 AM
Thanks for your response.

How would I "switch to Auto Properties"?
It's not easy to find in the documentation.
0
Serge
Telerik team
answered on 14 Nov 2011, 02:50 PM
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. 
0
Bitsmith
Top achievements
Rank 1
answered on 15 Nov 2011, 05:24 AM
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.
0
Serge
Telerik team
answered on 17 Nov 2011, 10:54 AM
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. 
0
Bitsmith
Top achievements
Rank 1
answered on 18 Nov 2011, 07:04 AM
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!!
Tags
Data Access Free Edition
Asked by
Bitsmith
Top achievements
Rank 1
Answers by
Serge
Telerik team
Bitsmith
Top achievements
Rank 1
Share this question
or