5

I have a project using ODP.Net version 12.2.1100. This project was working fine until opening today. The following line of code is causing the error:

using (var cn = new OracleConnection("User Name={userID}, etc, etc"))

The error being returned is:

Value cannot be null. Parameter name: path

Inner exception at System.Security.Permissions.FileIOPermission.CheckIllegalCharacters(String[] str, Boolean onlyCheckExtras)

Things I have tried so far to resolve the issue:

  1. Changed connection string from EZ Connect to full Oracle string
  2. Uninstalled and resintalled Oracle.ManagedDataAccess.dll (through NuGet)
  3. Ensured all config files were up to date
  4. Created a new simple test console project (which connected fine)
2
  • Always the same error? If yes, it seems to be unrelated to OracleConnection, esp. when you use the full Oracle string. Commented Oct 23, 2017 at 11:26
  • Yeah always the same error. I actually changed to an empty constructor and the same error. My instinct tells me its some configuration missing but nothing has appeared to change... Commented Oct 23, 2017 at 11:27

3 Answers 3

4

I had the same issue. It occurred also with the Managed Data Provider and it happens with the first Oracle class that gets instantiated, e.g. OracleParameter. But it only happens in the debugger of a unit test or in other cases where Assembly.GetEntryAssembly() returns null.

The call stack of the error gave me a hint: It calls System.Web.HttpRuntime.AppDomainAppPath. This throws the exception. By looking at the Oracle code I found a try-catch around it that should catch the exception but for some reason that sometimes fails. In another project I get the same exception but this time it gets caught before it hits my code. Strange. The following work around works for me:

        try
        {
            new OracleDependency();
        }
        catch
        {
        }

This triggers the static constructor of ConfigBaseClass and ignores the error. It is sufficient to call this once in your code, e.g. also in a static constructor. I used OracleDependency as it doesn't require a Dispose as most other Oracle classes.

Sign up to request clarification or add additional context in comments.

Comments

0

So next on my list was checking in my project and asking a colleague to open it to determine if the problem travelled with the code. He was able to execute successfully. I deleted my working copy and pulled it down from TFS, everything started working again. I suspect that something was corrupt in the bin directory.

Comments

0

I got this error in my integration test project. After deleting the bin folder and rebuilding, the error disappeared.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.