I am trying to use oracle odp.net driver to connect to Oracle database using webmatix. I would like to use webnatirx.data.
I used Database.OpenConnectionString(connectionString, providerName) with
providerName = "System.Data.OracleClient" in the past to connect to Oracle. From What I understand MSFT orcle client is deprecated. I am trying to switch to
providerName="Oracle.DataAccess.Client".
I am running in to issues. I am running this app on windows 7 64 bit version.
I get errors when I try to add Nuget ODP.NET package for 64 bit edition.
I appreciate if you can share your experience with odp.net
Thanks Mike for your quick response.. following are additional details.
Background: Trying to move a webmatrix project from win xp to Win 7 64 bit machine. Original app was developed using Webmatix 1.0 and got upgraded to 2.0 on XP. Code runs fine on XP with "System.Data.OracleClient". When I tried run the code on a new Windows
7 64 bit machine got a error message that lead me to the fact that latest version of .NET does not support MSFT oracle client and I should be using a 3rd party driver. I installed Oracle's ODP.net 64Bit version. I am able to connect to the Oracle Database
server using SQL Developer and also winforms test app using VS 2012. So that makes me believe that I have ODP installed and working. I am trying to modify the code in webmatrix to get it to work with ODP.net.
I tried so far few things, they are
STEP 1
Tried to add ODP.NET x64 NuGet package version 112.3.20
I get the following error message
======
Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
+0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
+34
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
+152
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38
[ConfigurationErrorsException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +752
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +258
System.Web.Compilation.BuildManager.ExecutePreAppStart() +135
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
+516
[HttpException (0x80004005): Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
=======
STEP 2: Added X86 version of NuGet Package (guessing it is a 32 bit one)
I get the following error with using client side debugging tools in Chrome.
=======
Unable to find the requested .Net Framework Data Provider. It may not be installed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.
Source Error:
Line 29: + " AND incdetail.genericboolean1 = '1' Order By Sortorder";
Line 30:
Line 31: var data = db.Query(selectQueryString, EmployeeID, PeriodName);
Line 32: db.Close();
Line 33:
If not, it might be better if I move your post to the Oracle forum as the issues seem to relate more to that than WebMatrix. Let me know if you would like the post moved.
There is no reason why you should not be able to use WebMatrix to get an ASP.NET site up and running with whatever database you choose.
My Guess is the issue might be Webmatrix being a 32 bit application and the driver I am using is 64 bit one. I am going to move the code to a regular visual studio project. I will miss the simplicity of WebMatrix.Data library. I will still have Razor goodness
under VS. I should be good.
I un-installed the 64 bit version Oracle .NET client and installed 32 bit version. I used the NuGet Package for 32 bit version and My WebMatrix code works w/o any changes other than making
providerName = "Oracle.DataAccess.Client"
Thanks for your help.
Regards,
Niranjan
Marked as answer by nravulapalli on Jan 23, 2013 01:54 AM
nravulapalli
0 Points
8 Posts
Oracle ODP.NET and WebMatrix
Jan 22, 2013 02:16 AM|LINK
I am trying to use oracle odp.net driver to connect to Oracle database using webmatix. I would like to use webnatirx.data.
I used Database.OpenConnectionString(connectionString, providerName) with
providerName = "System.Data.OracleClient" in the past to connect to Oracle. From What I understand MSFT orcle client is deprecated. I am trying to switch toI am running in to issues. I am running this app on windows 7 64 bit version.Mikesdotnett...
All-Star
154818 Points
19853 Posts
Moderator
MVP
Re: Oracle ODP.NET and WebMatrix
Jan 22, 2013 04:25 AM|LINK
If you want people to help you, you are going to have to provide some details.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
nravulapalli
0 Points
8 Posts
Re: Oracle ODP.NET and WebMatrix
Jan 22, 2013 03:03 PM|LINK
Thanks Mike for your quick response.. following are additional details.
Background: Trying to move a webmatrix project from win xp to Win 7 64 bit machine. Original app was developed using Webmatix 1.0 and got upgraded to 2.0 on XP. Code runs fine on XP with "System.Data.OracleClient". When I tried run the code on a new Windows 7 64 bit machine got a error message that lead me to the fact that latest version of .NET does not support MSFT oracle client and I should be using a 3rd party driver. I installed Oracle's ODP.net 64Bit version. I am able to connect to the Oracle Database server using SQL Developer and also winforms test app using VS 2012. So that makes me believe that I have ODP installed and working. I am trying to modify the code in webmatrix to get it to work with ODP.net.
I tried so far few things, they are
STEP 1
Tried to add ODP.NET x64 NuGet package version 112.3.20
I get the following error message
======
Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38
[ConfigurationErrorsException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +752
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +258
System.Web.Compilation.BuildManager.ExecutePreAppStart() +135
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516
[HttpException (0x80004005): Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
=======
STEP 2: Added X86 version of NuGet Package (guessing it is a 32 bit one)
The website runs
The psuedo code goes something like:
=======
Unable to find the requested .Net Framework Data Provider. It may not be installed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.
Source Error:
Line 29: + " AND incdetail.genericboolean1 = '1' Order By Sortorder";
Line 30:
Line 31: var data = db.Query(selectQueryString, EmployeeID, PeriodName);
Line 32: db.Close();
Line 33:
Source File: c:\Niranjan\CallidusMobile\Services\GetCallidusUserData.cshtml Line: 31
Stack Trace:
[ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.]
System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) +1425695
WebMatrix.Data.DbProviderFactoryWrapper.CreateConnection(String connectionString) +64
WebMatrix.Data.<>c__DisplayClass15.<OpenConnectionStringInternal>b__14() +16
WebMatrix.Data.Database.get_Connection() +19
WebMatrix.Data.Database.EnsureConnectionOpen() +12
WebMatrix.Data.<QueryInternal>d__0.MoveNext() +66
System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +381
System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
WebMatrix.Data.Database.Query(String commandText, Object[] parameters) +103
ASP._Page_Services_GetCallidusUserData_cshtml.Execute() in c:\Niranjan\CallidusMobile\Services\GetCallidusUserData.cshtml:31
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +69
System.Web.WebPages.WebPage.ExecutePageHierarchy() +151
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76
System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +114
====
I appreciate your help. Does Webmatrix work with ODP.NET?
Thanks,
Niranjan
Mikesdotnett...
All-Star
154818 Points
19853 Posts
Moderator
MVP
Re: Oracle ODP.NET and WebMatrix
Jan 22, 2013 05:52 PM|LINK
I have never used Oracle and know nothing about it, but see if this makes any sense to you: http://forums.asp.net/post/4281454.aspx
If not, it might be better if I move your post to the Oracle forum as the issues seem to relate more to that than WebMatrix. Let me know if you would like the post moved.
There is no reason why you should not be able to use WebMatrix to get an ASP.NET site up and running with whatever database you choose.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
nravulapalli
0 Points
8 Posts
Re: Oracle ODP.NET and WebMatrix
Jan 22, 2013 06:36 PM|LINK
My Guess is the issue might be Webmatrix being a 32 bit application and the driver I am using is 64 bit one. I am going to move the code to a regular visual studio project. I will miss the simplicity of WebMatrix.Data library. I will still have Razor goodness under VS. I should be good.
Thanks for your help.
Regards,
Niranjan
Mikesdotnett...
All-Star
154818 Points
19853 Posts
Moderator
MVP
Re: Oracle ODP.NET and WebMatrix
Jan 22, 2013 07:31 PM|LINK
So is Visual Studio.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
nravulapalli
0 Points
8 Posts
Re: Oracle ODP.NET and WebMatrix
Jan 23, 2013 01:54 AM|LINK
I un-installed the 64 bit version Oracle .NET client and installed 32 bit version. I used the NuGet Package for 32 bit version and My WebMatrix code works w/o any changes other than making
providerName = "Oracle.DataAccess.Client"
Thanks for your help.
Regards,
Niranjan