混淆删除了datacontext类

时间:2013-12-12 13:42:58

标签: c# .net entity-framework obfuscation eazfuscator

我正在尝试使用EAZfuscator混淆我的Winforms应用程序。当我尝试运行混淆的应用程序时,我得到一个实体框架异常(ProviderIncompatibleException)。

使用IlSpy来查看混淆的程序集 - 我注意到虽然我的大多数命名空间和类都保持原样(它似乎只是一些已重命名的变量名),但它已完全删除了我的DataContext类(即。派生自DbContext的那个。)

我假设我的ProviderIncompatibleException异常是由于需要匹配datacontext类名的连接字符串的名称。我在app.config中有这个:

<add name="DsDataContext" connectionString="Data Source=Database.sdf" providerName="System.Data.SqlServerCe.4.0" />

其中DsDataContext是从DbContext派生的类的名称(看起来已被Eazfuscator删除的名称)。

以前有没有人经历过这个?是什么原因导致Eazfuscator删除了这个类?此外,我很好奇为什么我的班级名称保持不变。混淆似乎没有被混淆。

更新

以下是完整性的例外情况。我认为由于上面提到的缺少课程,我得到了它:

输入:System.Data.ProviderIncompatibleException

消息:从数据库获取提供程序信息时发生错误。这可能是由实体框架使用不正确的连接字符串引起的。检查内部异常以获取详细信息,并确保连接字符串正确。

Source = EntityFramework

堆栈跟踪:

  at System.Data.Entity.ModelConfiguration.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)
  at System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest)
  at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
  at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
  at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
  at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
  at System.Data.Entity.Internal.InternalContext.CreateObjectContextForDdlOps()
  at System.Data.Entity.Database.Exists()
  at   .()
  at   .()

1 个答案:

答案 0 :(得分:5)

或者你的班级可能被混淆器重命名。

尝试将ObfuscationAttribute添加到您的数据上下文类:

[ObfuscationAttribute(Exclude=true)]