Question

I'm trying to obfuscate my Winforms app using EAZfuscator. When I try and run the obfuscated app, I get an Entity Framework exception (ProviderIncompatibleException).

Using IlSpy to look at the obfuscated assembly - I notice that whilst most of my namespaces and classes remain as they were (it just seems to be some variable names that have been renamed), it has completely removed my DataContext class (ie. the one that derives from DbContext).

I presume my ProviderIncompatibleException exception is due to the name of connection string needing to match the datacontext class name. I have this in my app.config:

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

Where DsDataContext is the name of my class that derives from DbContext (the one that appears to have been removed by Eazfuscator).

Has anyone experienced this before? Any reason why this class has been removed by Eazfuscator? Also, I'm curious to why my class names have remained intact. The obfuscation doesn't seem to be very obfuscated.

Update

Below is the exception for completeness. I presume I'm getting it due to the missing class I mention above though:

Type: System.Data.ProviderIncompatibleException

Message: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.

Source = EntityFramework

StackTrace:

  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   .()
Was it helpful?

Solution

Or maybe your class is being renamed by the obfuscator.

Try to add the ObfuscationAttribute to your data context class:

[ObfuscationAttribute(Exclude=true)]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top