[Oracle] FileNotFoundException when creating ObjectContext
Posted: Fri 13 Dec 2019 14:03
In short, I have a client which uses my framework to host his code. My framework allows to run client code in new AppDomain. So there can be couple of AppDomains hosted by one process. My client uses Devart dotConnect for Oracle to access his database and this was working fine so far.
The problem happened when client asked about obfuscated version of my framework. Nothing really changed in my code except my framework was obfuscated with ConfuserEX (see details below). Since then every time when client tried to access DB data he got following exception:
When client tried to access DB from main process (not from inside of AppDomain) everything worked! However this is not acceptable solution due to other constraints.
Finally I figured out that when I turn off one of Confuser protection rules (resources) problem disappears (see below).
I think this is a bug inside Devart library, I don't know what exactly you are doing inside Devart.Common.CRLicenseProvider.a(...) method, but documentation of method System.Reflection.RuntimeAssembly.GetManifestResourceStream(String) stays clearly it may throw FileNotFoundException.
The dotconnect for Oracle version used was 9.x (many projects, using many different versions of your library, all ending with the same issue).
The problem happened when client asked about obfuscated version of my framework. Nothing really changed in my code except my framework was obfuscated with ConfuserEX (see details below). Since then every time when client tried to access DB data he got following exception:
Code: Select all
Exception occured in mscorlib in Byte* GetResource(System.Reflection.RuntimeAssembly, System.String, UInt64 ByRef, System.Runtime.CompilerServices.StackCrawlMarkHandle, Boolean): Could not load file or assembly 'vLphEwYBDrCYdfNUCEXEFAdcMiEE, Version=0.0.0.0, Culture=neutral, PublicKeyToken=43b2a5dae6e35ee1' or one of its dependencies. The system cannot find the file specified. (stack trace:
at System.Reflection.RuntimeAssembly.GetResource(RuntimeAssembly assembly, String resourceName, UInt64& length, StackCrawlMarkHandle stackMark, Boolean skipSecurityCheck)
at System.Reflection.RuntimeAssembly.GetManifestResourceStream(String name, StackCrawlMark& stackMark, Boolean skipSecurityCheck)
at System.Reflection.RuntimeAssembly.GetManifestResourceStream(String name)
at Devart.Common.CRLicenseProvider.a(LicenseContext A_0, Type A_1, String& A_2, String& A_3, String& A_4)
at Devart.Common.CRLicenseProvider.a(LicenseContext A_0, Type A_1, String& A_2, Boolean& A_3, String& A_4, String& A_5)
at Devart.Common.CRLicenseProvider.a(LicenseContext A_0, Type A_1, Boolean A_2)
at Devart.Data.Oracle.OracleProviderFactory.CreateConnection()
at System.Data.EntityClient.EntityConnection.GetStoreConnection(DbProviderFactory factory)
at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
at System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString)
at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)
at Base.DomainModel.RTDB.RTDBEntities..ctor(String connectionString) in X:\Implementation\MSC\source\Base.DomainModel.RTDB\RTDBModel.Designer.cs:line 75
at Base.DbAccess.EntitiesFactory.GetRtdbEntities(Boolean lazyLoadingEnabled) in X:\Implementation\MSC\source\Base.DbAccess\EntitiesFactory.cs:line 59
at TPM.PCFCLOG.ContentHandlers.OnQuickStopFinalLoggingHandler.HandleEvent(Event eventContent) in X:\Implementation\MSC\source\TPM.PCFCLOG\ContentHandlers\OnQuickStopFinalLoggingHandler.cs:line 41)
Finally I figured out that when I turn off one of Confuser protection rules (resources) problem disappears (see below).
Code: Select all
<!-- part of ConfuserEx configuration file -->
<rule pattern="true" inherit="false">
<protection id="anti ildasm" />
<protection id="anti tamper" />
<protection id="ctrl flow" />
<protection id="ref proxy" />
<!-- commented due to issue with Devart library -->
<!-- <protection id="resources" /> -->
</rule>
The dotconnect for Oracle version used was 9.x (many projects, using many different versions of your library, all ending with the same issue).