Lightweight Oracle support in .NET core - oracle

I'm trying to connect to an Oracle database from a containerable dotnet core application, and haven't been able to find a solution that allows me to do this that fits all of these criteria:
Runs in .NET Core 2.0
Doesn't require extra installation on the machine running it (which would make it not Docker compatible)
Is free
I've tried many different solutions, and none of them actually connect. Most of the NuGet packages target .Net Standard or .Net Framework 4.6.1. The ones that I've found that are the most promising seem to have a different targeting issue and result in the following error:
System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Any suggestions?
Thank you for your time.

Oracle is now publishing an official Data Provider for .NET Core on nuget.

Related

What Non-4.* .NET App Versions play well with Standard?

I am building an MVC Web API (Service) with Views returned in specific cases. As an architectural decision, I've been directed to NOT build the service project in .NET Framework 4.*. Rather, I am to attempt .NET 5.0 first, and then Core 3.1 if 5.0 doesn't work.
This service project in my solution will depend on a few class library projects, call them DataLibrary, ComplexLibrary, and DocLibrary. DataLibrary will depend on a Nuget package of Oracle, be it ODP or Oracle Managed Data, in order to query an Oracle database via an Oracle Package on that database. DocLibrary will depend on a Nuget package of Aspose Word & Aspose PDF. ComplexLibrary will depend on Oracle AND Aspose.
Here's my dilemma:
Aspose Word's latest stable release (21.6) will report that it is compatible with 5.0 and Standard 2.0, but not .NET Core.
Oracle Managed Data reports that it is compatible with Standard 2.1 or Standard 2.0, but not 5.0 or .NET Core.
My own libraries have reported that they are not compatible with my API .csproj if...
3a. The API is 5.0 and the libraries are .NET Core or .NET Standard
3b. The API is Core 3.1 and the libraries are .NET Standard.
Since my compile script naturally requires a run of Nuget to retrieve all the necessary dependencies, I cannot get a clean compile because I seemingly have no combination of versions for my WebAPI and libraries that satisfy each others' compatibility needs. Since Standard libraries are the only common .NET version that satisfy the needs of both Aspose & Oracle, What available version for my WebAPI (i.e. I don't believe that Standard is an option for anything other than a class library) is compatible with .NET Standard libraries?
Thanks.
Please see the following article https://learn.microsoft.com/en-us/dotnet/standard/net-standard.
.NET Standard is not a framework it is kind f specification and .NET Core, .NET 5, Mono framework etc are .NET Standard implementations.
So for library projects I would select .NET Standard and for the service .NET Core or .NET 5 (which is actually the next version of .NET Core)
Well, don't I feel silly.
Turns out, the issue wasn't incompatibilities within Aspose, Office, .NET Core, 5.0, and Standard, but a failure of a prior version of NuGet to handle the different versions.
While my VS 2019 install was able to compile the whole solution effectively, my local install of NuGet was not. This was due to VS2019 likely using the most up-to-date version as of this post (5.9.#), while my locally installed version was 4.9.#. Thus, VS was able to sail through while my compile script kept failing at the NuGet stage (which I have included prior to the actual compile.) Once I ran a NuGet update, everything was good to go.
Long story short: KEEP YOUR NUGET VERSION UP-TO-DATE!!!

Is there a plan for coherence to support .net core projects?

I am creating a .Net core class library which I plan to publish as a Nuget package. As part of the requirement, I need to access a Oracle Coherence cache data source. Now Coherence dll doesn't seem to support .Net Core project at this moment. The .Net core application will run in non-windows environment. Has anybody faced a similar situation ? Does anybody know if Oracle Coherence is going to come up with .Net Core support ?
Yes, you can integrate you .NET module to a Coherene Cluster with the Extended Client API that are available in Java, .NET and C++.
I share with you the official doc:
https://docs.oracle.com/middleware/12213/coherence/develop-remote-clients/toc.htm
and .NET API:
https://docs.oracle.com/middleware/12213/coherence/net-reference/toc.htm

ASP.Net Core 2.2: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information

I recently started with ASP.Net Core 2.2. I have a situation where I need to use legacy SAP Connector library within my application. After some reading I created my application to target full .Net Framework 4.6.1. I have a test class that references the SAP Connector library.
However, when I run my application, it breaks within Startup.cs right where it calls this line:
app.UseMvc();
Checking the LoaderExceptions property, it shows the error:
Could not load file or assembly 'sapnco, Version=3.0.0.42, Culture=neutral, PublicKeyToken=50436dca5c7f7d23' or one of its dependencies. An attempt was made to load a program with an incorrect format.
My hunch is that although ASP.Net Core supports full .Net Framework, the referenced assembly has to go as far back to particular version of .Net Framework and no less. Although I can't find any concrete info on that.
Please help!
For SAP Connector, I think you need to contact SAP Forum Support to confirm if the SAP Connector .NET Core version is available or will be available.
From the perspective of .Net Core, I am afraid there are no connectors and no plans to develop such connectors.

How to run odp.net application in both .net 3.5 and .net 4

I am working on an internal tool for our product. Our product uses oracle database and have evolved over time from .net framework 2.0 to 4.5 and Oracle 10 to 12.2.
The aim of the tool is to write a single application which works across different versions of the product.
I have solved the problem of multiple .net framework versions by using the following entries in app.config
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v4.0"/>
As the oracle managed .net driver is supported for framework >=4.0, I can not use this as I have to support .net framework 3.5 also.
As I have to use unmanaged odp.net driver, I was thinking about the following scenario
My tool would use the lowest version of oracle.dataaccess.dll and target .net 3.5.
Following #1 above makes me refer to 2.xx.... version of the oracle.dataaccess.dll.
When I run this application on a machine with only .net framework 4 installed, what would be the behavior? Would it load 4.xx... version of oracle.dataaccess dll when running under the context of .net framework 4?
The best solution for this would have been availability of oracle managed driver for .net 3.5 version but I found that it is not available.
Please provide your valuable inputs.
Satish
UPDATE :
I have written a sample application targeting .net framework 3.5. In this sample app, I will build a connection string and just open a connection and close it.
This application runs successfully when there are no <supportedRuntime> tags in the app.config.
When we add any <supportedRuntime> tags in the app.config, I am getting a type initializer exception for oracle related types. I have tried this with the supported run time tags
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v4.0"/>
individually and both combined. But I am still getting the issue. Can anyone suggest how to resolve this issue?
ODP.NET unmanaged driver exist in following versions:
1.x (.NET Framework 1.0.3705/1.1.4322), available up to Oracle Client 11.1.
2.0 (.NET Framework 2.0.50727), introduced with Oracle Client 10.2
4.0 (.NET Framework 4.0.30319), introduced with Oracle Client 11.2
If your compile target is .NET version 3 or 3.5 then the application will try to load ODP.NET version 2.0 (and will raise an exception if it is not found on the machine). Actually I am not sure if it would also accept ODP.NET version 4.0.
If your compile target is .NET version 4 or higher then the application will try to load ODP.NET version 4.0 (and will raise an exception if it is not found on the machine).
You can do several solutions:
Provide a copy of Oracle.DataAccess.dll which matches your version and put it in your application directory.
Use late binding, i.e. instead of
var con = new Oracle.DataAccess.Client.OracleConnection();
use
var DLL = Assembly.Load(String.Format("Oracle.DataAccess, Version={0}.{1}.*.*, Culture=neutral, PublicKeyToken=89b483f429c47342", frameworkVersion, oracleVersion));
var type = DLL.GetType("Oracle.DataAccess.Client.OracleConnection", true, false);
dynamic con = Activator.CreateInstance(type)
However, this syntax is only available from .NET Framework version 4.0 on, I do not know how to write this in version 3.0/3.5.
Note, use con.GetType().Assembly.FullName and con.GetType().Assembly.Location in order to see which DLL was really loaded.

Windows CE project with libraries problem

I am developing a Windows CE application which uses some libraries provided by other parts of our company.
When I deploy my application on "My Computer" (.NET compact application running on standard PC), everything works, but when I deploy to the device, the application hangs when trying to use methods from the library. The system also hangs. My Visual Studio 2008 sometime hangs, but sometime throws an exception "TypeLoadException: Could not load type from assembly Culture=neutral, PublicKeyToken=nu".
I couldn't include .NET Compact framework 3.5 because the image wouldn't compile, so I am using version 2.0. I use Visual Studio 2008 with deploy .NET framework option.
Most probably the problem is with version of the library you are using. Please cross check it.
Hope this link will help you.
I'm a bit confused.
First of all, what are the libraries "provided by other parts of [y]our company" build against? Are they Compact Framework assemblies (they must be)? What version of the Framework were they build against? Reflector can tell you this if you don't know.
Second, why can't you compile it with 3.5? What sort of errors are you seeing? The code should be 100% forward compatible, so if it won't build, there's a red flag going up.
Lastly, what version of the CF is installed on the target hardware? FOr example, are you trying to push a CF 2.0 app to a device with CF 3.5 already installed? If so, do you have an app.config file that provides the framework compatibility options so it knows it can run your assembly?
The problem was that libraries were compiled with for 3.5 target framework, and the application which uses them form 2.0 framework. In that case, 3.5 framework wasn't depoloyed and application would stop working as soon as call to the library methods was made.

Resources