This discussion is archived
1 2 Previous Next 15 Replies Latest reply: Oct 2, 2012 3:48 AM by Johnsung RSS

ODP.NET and Visual Studio 2010

956254 Newbie
Currently Being Moderated
I'm trying to start fresh with Visual Studio 2010 and want to use ODP.NETboth in a x64 environment in development and on the server. I have installed 11G 11.2 on my Windows 7 laptop so the Oracle.DataAccess.dll version in odp.net/bin/2.x is 2.112.1.0. I created a brand new empty .NET web application for .NET framework 4 and then set the build to be x64 and then added the dll as a reference. It builds ok but when it runs it says "Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies.

From what I've read, that happens when you are mixing 32 and 64 bit. I have confirmed with dependency walker that Oracle.DataAccess.dll is 64bit.

Any ideas?

Edited by: bennettaj on Sep 26, 2012 12:21 PM
  • 1. Re: ODP.NET and Visual Studio 2010
    Johnsung Pro
    Currently Being Moderated
    Hello Bennettaj,

    I wanted to clarify:
    You said "odp.net/bin/2.x is 2.112.1.0. I created a brand new empty .NET web application for .NET framework 4"

    So do you actually mean you added the reference to the ODP.net 4.0 library 4.112.1.x (not the version 2.x library?)
    For applications running on top of the .NET Framework 4.0 or higher, you must use the Oracle.DataAccess assembly that is for
    Framework 4.x or higher. i.e 4.112.1.2.

    If you don't have that then can you try downloading the latest 11.2.0.3 ODAC (currently release 5) that should have the 4.0 Framework
    library.

    The alternative is to build using .net 2.0 instead.

    Hope this helps.

    John
  • 2. Re: ODP.NET and Visual Studio 2010
    956254 Newbie
    Currently Being Moderated
    Yes, I realized just after I posted that I should be using the 4.112.1.x. I have tried to use that as well but when it runs, it says

    CS0246: The type or namespace name 'Oracle' could not be found (are you missing a using directive or an assembly reference?)

    I have the 4.112.1.x dll in my bin folder and it compiles ok, just can't get it to run correctly.
  • 3. Re: ODP.NET and Visual Studio 2010
    Johnsung Pro
    Currently Being Moderated
    You said it compiles ok but isn't the CS0246 a compile time error?
    If you get the error with a very simple example source can you post the example here to help us understand what might be wrong.

    for example if you try this :
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    using System.Text;
    
    namespace test1
    {
        class Program
        {
            static void Main(string[] args)
            {
                OracleConnection cn = new OracleConnection("User ID=scott;Password=tiger; Data Source=orcl");
                cn.Open();
                Console.Write("Done \n");
                cn.Close();
    
            }
        }
    }
    John
  • 4. Re: ODP.NET and Visual Studio 2010
    956254 Newbie
    Currently Being Moderated
    Sorry, I meant builds ok. When I run it, it is when it shows me the compiler error. I have written the code which connects but since it wasn't working, I stripped it down to just the includes at the top. This is the whole page now:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.Configuration;
    using Oracle.DataAccess.Client;

    namespace LWF_POC
    {
    public partial class Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public void btnDoSomething_Clickonclick(object sender, EventArgs e)
    {

    System.Configuration.ConnectionStringSettingsCollection connections =WebConfigurationManager.ConnectionStrings;

    txtCarrierName.Text = connections["LWFConnection"].ConnectionString;
    }



    }
    }

    Sorry for the randomness of the names/code and what it's doing. Just messing around trying to get things figured out.

    Here is the error:

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS0246: The type or namespace name 'Oracle' could not be found (are you missing a using directive or an assembly reference?)

    Source Error:


    Line 6: using System.Web.UI.WebControls;
    Line 7: using System.Web.Configuration;
    Line 8: using Oracle.DataAccess.Client;
    Line 9:
    Line 10: namespace LWF_POC

    Source File: c:\Apps\1LWF\LWF_POC\LWF_POC\LWF_POC\Default.aspx.cs Line: 8

    Edited by: bennettaj on Sep 27, 2012 6:01 AM
  • 5. Re: ODP.NET and Visual Studio 2010
    Johnsung Pro
    Currently Being Moderated
    The sample code you had wasn't really what I was expecting - as there is no reference to ODP.net in your code apart from in the "using" clause.

    can you paste what you have in visual Studio for the "Path" property of your "Oracle.DataAccess" reference?
    also what version is it showing.

    Finally what ODP.net download did you download /install? What was the filename?

    John
  • 6. Re: ODP.NET and Visual Studio 2010
    956254 Newbie
    Currently Being Moderated
    C:\oracle\odp.net\bin\4\Oracle.DataAccess.dll

    Version: 4.112.2.0

    I first installed ODAC112021Xcopy_x64 and then win64_11gR2_client

    Since I didn't see the version 4 in the C:\oracle\product\11.2.0\client_1\ODP.NET\bin folder, I pointed to the original one I installed in C:\oracle\odp.net\bin\ folder.

    Edited by: bennettaj on Sep 27, 2012 8:13 AM
  • 7. Re: ODP.NET and Visual Studio 2010
    Johnsung Pro
    Currently Being Moderated
    Can you deinstall the 11.2.0.1 client that you installed in "C:\oracle\product\11.2.0\client_1" just to ensure that is not related to the problem?
    I'm wondering if by installing the 2nd client it changed some of the redirections via publisher policies.
    So let's get rid of that first and see.

    John
  • 8. Re: ODP.NET and Visual Studio 2010
    956254 Newbie
    Currently Being Moderated
    OK so I ran the Universal Installer to remove and it says to run the deinstall (c:\oracle\product\11.2.0\client_1/deinstall/deinstall) which I did. It seemed to complete successfully (I tried 3 times) but all the files are still there. When I run the Universal Installer again it still says that client is installed.

    I tried running the code again and still get the same error. I'm not convinced anything is being uninstalled. Is there a different way?
  • 9. Re: ODP.NET and Visual Studio 2010
    Johnsung Pro
    Currently Being Moderated
    Hmm this gets more complicated as we go:)
    I can't say what the deinstall issue is and why it's leaving all the files..
    As an alternative can you install the 64 bit ODAC 11.2.0.3 release 5 ?
    This might be the best way to get a working configuration..
  • 10. Re: ODP.NET and Visual Studio 2010
    956254 Newbie
    Currently Being Moderated
    Yes, welcome to my world lately :) I have been going in rounds like this with it.

    I would usually have no problem upgrading to the latest but our web host has not upgraded to the latest Oracle client so I'd rather stick with the same one they have so I don't have issues on the deployment. Any thoughts?
  • 11. Re: ODP.NET and Visual Studio 2010
    956254 Newbie
    Currently Being Moderated
    OK good news. I ran the .bat as an Administrator (my helpdesk keeps telling me I am an Admin but I don't believe them) and it removed the files and the Universal Installer is not an option in Programs anymore. So I ran the code again after that and still the same.
  • 12. Re: ODP.NET and Visual Studio 2010
    956254 Newbie
    Currently Being Moderated
    OK good news. I ran the .bat as an Administrator (my helpdesk keeps telling me I am an Admin but I don't believe them) and it removed the files and the Universal Installer is not an option in Programs anymore. So I ran the code again after that and still the same.
  • 13. Re: ODP.NET and Visual Studio 2010
    Johnsung Pro
    Currently Being Moderated
    OK, going on the basis the previous install may have overwritten something can you rerun the xcopy 11.2.0.2 install to see if that has any effect?
    I would suggest strongly to use 11.2.0.3 - as it is not a major version upgrade it should be safe to do.
  • 14. Re: ODP.NET and Visual Studio 2010
    956254 Newbie
    Currently Being Moderated
    OK today I have uninstalled everything and just installed the 32bit version. That works just fine, as expected. I think I just needed confirmation that at least that would work.

    I then tried to uninstall everything and start fresh with the 11.2.0.3 64bit version and the install is failling at the end. I remember now trying this early on in trying to get this to work and it's part of the reason I was sticking with the earlier versions. It says "error occurred during runtime". I think it has something to do with when it is trying to add the assemblies to the gac.
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points