相关疑难解决方法(0)

'System.Data.Entity.Internal.AppConfig'的类型初始化程序在子网站上引发了一个例外

我有2个网站,一个是另一个的子目录,但是是一个Application ex:/ root&/ root/Services

他们都使用Entity Framework 6.x,但子网站正在抛出System.Data.Entity.Internal.AppConfig的类型初始化程序'引发了一个异常,因为它看起来因为嵌套而看到同一个EF数据库提供程序的许多条目web.config中

有没有办法清除提供程序集合,以便我不会收到此错误?我试过放入哪个没效果.

如果我注释掉提供者部分它是有效的

<providers>
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
Run Code Online (Sandbox Code Playgroud)

但我不想这样做,因为不是每个环境都会有嵌套网站.并且NuGet倾向于将其重新插入.我可以通过编程方式进行调整吗?

这是完整的异常和堆栈跟踪

System.TypeInitializationException was unhandled by user code
HResult=-2146233036
Message=**The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.**
Source=EntityFramework
TypeName=System.Data.Entity.Internal.AppConfig
StackTrace:
     at System.Data.Entity.Internal.AppConfig.get_DefaultInstance()
     at System.Data.Entity.Internal.LazyInternalConnection..ctor(String nameOrConnectionString)
     at System.Data.Entity.DbContext..ctor(String nameOrConnectionString)
     at co.Repository.Data.coContext..ctor() in coModel.Context.Generated.cs:line 23
     at co.Repository.RepositoryBase`1.SingleOrDefault(Expression`1 predicate) in co.Repository\RepositoryBase.cs:line 13
     at UserFactory.GetOneByUserName(String siteCode, String userName) in UserFactory.cs:line 151
     at UserService.GetOneByUserName(String siteCode, String userName) in UserService.cs:line 59
     at SyncInvokeGetOneByUserName(Object , Object[] , Object[] …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework nuget entity-framework-6

16
推荐指数
3
解决办法
6万
查看次数

停止从IIS 7.5中的父ASP.NET应用程序继承web.config

我们在IIS 7.5中部署了一个ASP.NET网站(App 1).然后在该应用程序下创建另一个ASP.NET应用程序(App 2).但在App 2中,我不想继承web.configApp 1.

如果我尝试在App 1中执行以下操作,web.config:

<location path="." inheritInChildApplications="false"> 
    <configSections> 

    <!-- etc -->

    </configSections>
</location>
Run Code Online (Sandbox Code Playgroud)

它报告错误:

配置错误配置部分'configSections'无法读取,因为它缺少部分声明

如果我尝试做:

<remove name = "system.web.extensions" /> 
Run Code Online (Sandbox Code Playgroud)

它仍然报告相同的错误:

asp.net configuration web-config

11
推荐指数
2
解决办法
3万
查看次数