1

I have written a program with .net framework 4.8, ef.6.4 in Windows 11, and I have no problems when debugging, but when I release the program and run it on Windows 7 (x86), I encounter the following error when initializing the database. I will I have also put the stack of it, please help me:

Error -> Dynamic operations can only be performed in homogenous AppDomain.

stack :

at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite`1 site, Object[] args)
   at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid2[T0,T1](CallSite site, T0 arg0, T1 arg1)
   at System.Data.Entity.SqlServer.SqlServerMigrationSqlGenerator.<GenerateStatements>b__10_0(Object o)
   at System.Data.Entity.SqlServer.Utilities.IEnumerableExtensions.Each[T](IEnumerable`1 ts, Action`1 action)
   at System.Data.Entity.SqlServer.SqlServerMigrationSqlGenerator.GenerateStatements(IEnumerable`1 migrationOperations)
   at System.Data.Entity.SqlServer.SqlServerMigrationSqlGenerator.Generate(IEnumerable`1 migrationOperations, String providerManifestToken)
   at System.Data.Entity.Migrations.DbMigrator.GenerateStatements(IList`1 operations, String migrationId)
   at System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, VersionedModel targetModel, IEnumerable`1 operations, IEnumerable`1 systemOperations, Boolean downgrading, Boolean auto)
   at System.Data.Entity.Migrations.DbMigrator.AutoMigrate(String migrationId, VersionedModel sourceModel, VersionedModel targetModel, Boolean downgrading)
   at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
   at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
   at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClass42_0.<Update>b__0()
   at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
   at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
   at System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext internalContext, Func`3 createMigrator, ObjectContext objectContext)
   at System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext objectContext, DatabaseExistenceState existenceState)
   at System.Data.Entity.Database.Create(DatabaseExistenceState existenceState)
   at System.Data.Entity.DropCreateDatabaseIfModelChanges`1.InitializeDatabase(TContext context)
   at System.Data.Entity.Internal.InternalContext.<>c__DisplayClass66_0`1.<CreateInitializationAction>b__0()
   at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)
   at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
   at System.Data.Entity.Database.Initialize(Boolean force)
   at EventsPortal.Managers.ConnectionManager.Connect(Boolean force)

When I was searching for a solution, the only solution I found was to disable <trust legacyCasModel="true" level="Full" /> in web.config, which I don't have such settings in my program.

wp78de
  • 18,207
  • 7
  • 43
  • 71
ROMO
  • 13
  • 4
  • There are multiple questions about this error on SO, have you checked them? Most seem to point to a `legacyCasModel/Policy` setting. See: https://stackoverflow.com/a/16159661/8291949 – wp78de Dec 24 '22 at 17:12
  • Yes . As I said before, I have searched and read all the questions related to this problem and all the answers refer to "legacyCasModel/Policy", but my problem was not solved. This is because there is no such statement in my config file.Or maybe I don't know how to find this expression in the Config file. I think the problem is somewhere else that I don't know – ROMO Dec 24 '22 at 17:20
  • I'd try `` in the app.config then. – wp78de Dec 24 '22 at 17:24
  • Do you have .NET 4.8 installed on the Windows 7 system as well? – wp78de Dec 24 '22 at 17:30
  • There is no such statement in my app.config. – ROMO Dec 25 '22 at 04:00
  • Yes I install .net4.8 in windows 7 – ROMO Dec 25 '22 at 04:01
  • Add the element like so: ` ` https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/netfx40-legacysecuritypolicy-element – wp78de Dec 25 '22 at 04:43
  • by the way why you are using .net 4.8 instead of atleast .net 6.0? – Kamran Shahid Dec 26 '22 at 15:58
  • @KamranShahid .net 4.8 is still supported – Daniel A. White Jan 04 '23 at 17:43
  • yes . just an advice that he can try with .net 6 or newer and check – Kamran Shahid Jan 08 '23 at 18:13
  • Some of my important software are not compatible with higher versions – ROMO Jan 13 '23 at 20:19

0 Answers0