security transparent method exception issue

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
Noodleloaf
Posts: 1
Joined: Mon 23 May 2022 18:24

security transparent method exception issue

Post by Noodleloaf » Mon 23 May 2022 18:27

I have a .NET 4.8 project that runs fine on my dev machine but when deployed hits the following exception. Any guidance on what can be causing and how to resolve is appreciated. It is time-sensitive to resolve. Thanks.

Server Error in '/' Application.
Attempt by security transparent method 'Devart.Data.MySql.Entity.t.a()' to access security critical method 'Devart.Data.MySql.MySqlCommand..ctor()' failed.

Assembly 'Devart.Data.MySql.Entity.EF5, Version=8.21.2066.0, Culture=neutral, PublicKeyToken=09af7300eec23701' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.MethodAccessException: Attempt by security transparent method 'Devart.Data.MySql.Entity.t.a()' to access security critical method 'Devart.Data.MySql.MySqlCommand..ctor()' failed.

Assembly 'Devart.Data.MySql.Entity.EF5, Version=8.21.2066.0, Culture=neutral, PublicKeyToken=09af7300eec23701' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[MethodAccessException: Attempt by security transparent method 'Devart.Data.MySql.Entity.t.a()' to access security critical method 'Devart.Data.MySql.MySqlCommand..ctor()' failed.

Assembly 'Devart.Data.MySql.Entity.EF5, Version=8.21.2066.0, Culture=neutral, PublicKeyToken=09af7300eec23701' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.]
Devart.Data.MySql.Entity.t.a() +30
Devart.Common.Entity.ew.c() +65
Devart.Data.MySql.Entity.MySqlEntityProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree) +76
System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree) +423

[EntityCommandCompilationException: An error occurred while preparing the command definition. See the inner exception for details.]
System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree) +2080
System.Data.EntityClient.EntityProviderServices.CreateCommandDefinition(DbProviderFactory storeProviderFactory, DbCommandTree commandTree) +53
System.Data.Objects.Internal.ObjectQueryExecutionPlan.Prepare(ObjectContext context, DbQueryCommandTree tree, Type elementType, MergeOption mergeOption, Span span, ReadOnlyCollection`1 compiledQueryParameters, AliasGenerator aliasGenerator) +980
System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption) +1277
System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +218
System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +41
System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +430
System.Linq.Enumerable.ToList(IEnumerable`1 source) +73
ccTracking.complaint.Page_Load(Object sender, EventArgs e) in C:\Users\Costco Member\Desktop\Ryan_Dev\npTracking\ccTracking\complaint.aspx.cs:146
System.Web.UI.Control.OnLoad(EventArgs e) +108
System.Web.UI.Control.LoadRecursive() +90
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1533

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4261.0

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: security transparent method exception issue

Post by Shalex » Tue 04 Oct 2022 17:11

dotConnect for MySQL v8.21.2066 and higher versions include the following improvements:
  • The new \Entity\EF5\net47\Devart.Data.MySql.Entity.EF5.dll assembly compiled with .NET Framework 4.7 is added
  • The behavior is changed: Devart.Data.MySql.Entity.EF5.dll compiled with .NET Framework 4.7 is used now in EF5 models
With v8.21.2066, you should add the following references to your project and use them during deployment:
* C:\Program Files (x86)\Devart\dotConnect\MySQL\NET4\Devart.Data.dll
* C:\Program Files (x86)\Devart\dotConnect\MySQL\NET4\Devart.Data.MySql.dll
* C:\Program Files (x86)\Devart\dotConnect\MySQL\Entity\EF5\net47\Devart.Data.MySql.Entity.EF5.dll

Post Reply