Asp.net mvc 实体框架6的System.TypeLoadException

Asp.net mvc 实体框架6的System.TypeLoadException,asp.net-mvc,iis,entity-framework-6,Asp.net Mvc,Iis,Entity Framework 6,我在IIS中对我的网站进行了二倍体处理并尝试在浏览器中查看页面后,遇到了以下错误 无法从加载类型“DienstbulletinApp.DienstBulletinoText” 组件“DienstbulletinApp”。描述:未处理的异常 在执行当前web请求期间发生。请 查看堆栈跟踪以了解有关错误和位置的更多信息 它起源于代码 异常详细信息:System.TypeLoadException:无法加载类型 来自程序集的“DienstbulletinApp.DienstBulletinoText”

我在IIS中对我的网站进行了二倍体处理并尝试在浏览器中查看页面后,遇到了以下错误

无法从加载类型“DienstbulletinApp.DienstBulletinoText” 组件“DienstbulletinApp”。描述:未处理的异常 在执行当前web请求期间发生。请 查看堆栈跟踪以了解有关错误和位置的更多信息 它起源于代码

异常详细信息:System.TypeLoadException:无法加载类型 来自程序集的“DienstbulletinApp.DienstBulletinoText” “迪恩斯布吕蒂纳普”

当我在visual studio 2019中运行我的应用程序时,我没有这个错误。 我已经从我的webconfig文件中删除了上下文,但似乎没有解决方案

 <contexts>
      <context type="DienstbulletinApp.DAL.DienstbulletinAppContext, DienstbulletinApp, Version=1.0.0.0, Culture=neutral">
        <databaseInitializer type="DienstbulletinApp.DAL.DienstbulletinAppInitializer, DienstbulletinApp, Version=1.0.0.0, Culture=neutral" />
      </context>
    </contexts>

迪恩斯特文本:

 public class DienstbulletinAppContext : DbContext
    {
        public DienstbulletinAppContext() : base("name=DienstbulletinDBConnectionString")
        {
            Database.SetInitializer(new DienstbulletinAppInitializer());

        }
        public DbSet<Dienstbulletin> Dienstbulletins { get; set; }
        public DbSet<Voertuig> Voertuigen { get; set; }
        public DbSet<Opdracht> Opdrachts { get; set; }
        public DbSet<DienstbulletinDetail> DienstbulletinDetails { get; set; }
        public DbSet<Locatie> Locaties { get; set; }
        public DbSet<Gebruiker> Gebruikers { get; set; }
        public DbSet<Persoon> Personen { get; set; }
        public DbSet<OpdrachtType> OpdrachtTypes { get; set; }
        public DbSet<Aandachtspunt> Aandachtspunten { get; set; }
        public DbSet<Gsm> Gsms { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Persoon>().ToTable("t_Persoon");
            modelBuilder.Entity<Voertuig>().ToTable("t_Voertuig");
            modelBuilder.Entity<Gebruiker>().ToTable("t_Gebruiker");
            modelBuilder.Entity<OpdrachtType>().ToTable("t_OpdrachtType");
            modelBuilder.Entity<Opdracht>().ToTable("t_Opdracht");
            modelBuilder.Entity<Dienstbulletin>().ToTable("t_Dienstbulletin");
            modelBuilder.Entity<DienstbulletinDetail>().ToTable("t_DienstbulletinDetail");
            modelBuilder.Entity<Locatie>().ToTable("t_Locatie");
            modelBuilder.Entity<Aandachtspunt>().ToTable("t_Aandachtspunt");
            modelBuilder.Entity<Gsm>().ToTable("t_Gsm");

            modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
        }
    }
公共类diensBulletinAppContext:DbContext
{
public diensBulletinAppContext():base(“name=diensBulletindBConnectionString”)
{
SetInitializer(新的DiensBulletinAppInitializer());
}
公共DbSet Dienstbulletins{get;set;}
公共DbSet Voertuigen{get;set;}
公共DbSet Opdrachts{get;set;}
公共DbSet dienstbuilletindetails{get;set;}
公共数据库集位置{get;set;}
公共数据库集Gebruikers{get;set;}
公共DbSet Personen{get;set;}
公共DbSet OpdrachtTypes{get;set;}
公共数据库集
System.Data.Entity.Internal.InitializerConfig.TryGetInitializer(类型requiredContextType、字符串contextTypeName、字符串initializerTypeName、布尔值isDisabled、Func
1 initializerArgs、Func
3 exceptionMessage)+327 System.Data.Entity.Internal.InitializerConfig.TryGetInitializerFromLegacyConfig(类型contextType)+644 System.Data.Entity.Internal.InitializerConfig.TryGetInitializer(类型contextType)+39 System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetServiceFactory(类型、字符串名称)+513 System.Collections.Concurrent.ConcurrentDictionary
2.GetOrAdd(TKey,Func
2 valueFactory)+87 System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetService(类型,对象键)+187 System.Linq.WhereSelectArrayIterator
2.MoveNext()+78
System.Linq.Enumerable.FirstOrDefault(IEnumerable
1源代码,Func
2谓词)+115
System.Data.Entity.Infrastructure.DependencyResolution.CompositeResolver
2.GetService(类型,对象键)+41 System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()+159 System.Data.Entity.Internal.RetryAction
1.PerformAction(TInput输入)+171
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action
1 Action)+269 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(类型entityType)+20 System.Data.Entity.Internal.Linq.InternalSet
1.Initialize()+69
System.Data.Entity.Internal.Linq.InternalSet
1.get\u InternalContext()+21 System.Data.Entity.Infrastructure.DbQuery
1.System.Linq.IQueryable.get\u Provider()+59
System.Linq.Queryable.FirstOrDefault(IQueryable
1源代码,表达式
1谓词)+61
D:\Plastic\DienstbulletinApp.Controller.GebruikerController.Login()中的DienstbulletinApp.Controller.GebruikerController.Login()
lambda_方法(闭包、控制器基、对象[])+87
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext ControllerContext,ActionDescriptor ActionDescriptor,IDictionary
2个参数)+35 System.Web.Mvc.Async.c.b_9_0(IAsyncResult asyncResult,ActionInvocation innerInvokeState)+39 System.Web.Mvc.Async.WrappedAsyncResult
2.CallEndDelegate(IAsyncResult asyncResult)+70
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)+42
System.Web.Mvc.Async.c_uuuudisplayClass11_0.b_uuu0()+80
System.Web.Mvc.Async.c\uuuu DisplayClass11\u2.b\uuu2()+387
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)+42
System.Web.Mvc.Async.c\uuuu DisplayClass3\u6.b\uu4()+50
System.Web.Mvc.Async.c__显示类3_1.b_1(IAsyncResult asyncResult)+188
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)+38
System.Web.Mvc.c.b__152_1(IAsyncResult asyncResult,ExecuteCorerate innerState)+26
System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult asyncResult)+68 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)+52 System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult asyncResult)+39
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)+38
System.Web.Mvc.c.b_20_1(IAsyncResult asyncResult,ProcessRequestState innerState)+40
System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult asyncResult)+68 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)+38 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+602 System.Web.HttpApplication.executesteppl(IExecutionStep步骤)+195 System.Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔值&同步完成)+128


发现从上下文中删除版本和区域性=中性时出错解决了此问题:

<contexts>
  <context type="DienstbulletinApp.DAL.DienstbulletinAppContext, DienstbulletinApp">
    <databaseInitializer type="DienstbulletinApp.DAL.DienstbulletinAppInitializer, DienstbulletinApp" />
  </context>
</contexts>

将代码推送到IIS时,是否可以确认正在发布.DLL?请确保DLL引用的属性
Copy Local
设置为true
DienstbulletinApp.DienstBulletinoText
。@您的意思是“复制到输出目录”吗设置为true。这会生成DLL吗?DienstbulletinApp.DienstbulletinContext只是我的解决方案中的一个类