[Oracle] FileNotFoundException when creating ObjectContext

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
daro
Posts: 2
Joined: Fri 13 Dec 2019 13:20

[Oracle] FileNotFoundException when creating ObjectContext

Post by daro » 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:

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)
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).

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>
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).

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: [Oracle] FileNotFoundException when creating ObjectContext

Post by Shalex » Mon 23 Dec 2019 14:28

Devart.Common.CRLicenseProvider.a(...) looks for the embedded license resource MyApplication.exe.licenses, you can find out the exact name of license resource by decompiling assembly before obfuscation. After obfuscation, check if the name of the license resource remained unchanged.

daro
Posts: 2
Joined: Fri 13 Dec 2019 13:20

Re: [Oracle] FileNotFoundException when creating ObjectContext

Post by daro » Tue 07 Jan 2020 08:31

The problem is that only my framework assemblies are obfuscated, while Devart is used by client assemblies which are not obfuscated.
That's why I think there is a bug in Devart, which looks for the embedded license resource - the code is not prepared to handle list of resources which are some obfuscated and some not. The MyApplication.exe.licenses resource is available and not obfuscated inside client assemblies.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: [Oracle] FileNotFoundException when creating ObjectContext

Post by Shalex » Fri 10 Jan 2020 10:00

Could you please upload a small complete test project with the required assemblies for reproducing the issue to some file exchange server and provide the download link via our contact form?

Post Reply