I'm developing an Azure webjob using .NET Framework but when I'll run this localy, I've this exception after the startup.
Microsoft.Azure.WebJobs.Host.Listeners.FunctionListenerException: The listener for function [Name of function] was unable to start.
Inner exception:
ArgumentNullException: Value cannot be null.
Parameter name: connectionString
This is the code inside the Program class of the web job.
static void Main()
{
HostBuilder builder = new HostBuilder();
builder.ConfigureWebJobs(b =>
{
b.AddAzureStorageCoreServices();
b.AddTimers();
});
using (IHost host = builder.Build())
{
host.Run(); // <-- error happens on this line
}
}
Inside the App.config I've added next two connection strings:
<add name="AzureWebJobsDashboard" connectionString="DefaultEndpointsProtocol=https;AccountName=[Name];AccountKey=[Key]" />
<add name="AzureWebJobsStorage" connectionString="DefaultEndpointsProtocol=https;AccountName=[Name];AccountKey=[Key]" />
With [Name] and [Key] as the account name en key from a live environment.
Also when I change the connection strings to UseDevelopmentStorage=true, I'm getting the same exception.
How could I solve this?
Update:
If you're using Azure WebJobs SDK of version 3.x with .NET Framework, there is an issue: Version 3.x is incompatible with .NET Framework and PackageReference.
So there're several ways as workaround:
Directly use the Azure WebJobs template from Visual studio, it's based on .net framework.
You can add an appsettings.json file (Note: right click the file → select Properties → then set "Copy to Output Directory" to "Copy if newer") to the .NET Framework project, it will work(based on 1, it will throw errors, but it can work). The JSON file looks like below:
{
"AzureWebJobsStorage": "{storage connection string}"
}
The best solution is to use .NET Core with WebJobs SDK of version 3.x.
Original answer:
If you're using WebJob SDK version 3.x, I suggest you should create a .NET Core console project instead of .NET Framework console project, then you should follow this official doc.
First, create a .NET Core console app. And install all the necessary packages mentioned in the official doc.
Your program.cs:
static void Main()
{
HostBuilder builder = new HostBuilder();
builder.ConfigureWebJobs(b =>
{
b.AddAzureStorageCoreServices();
b.AddAzureStorage();
b.AddTimers();
});
using (IHost host = builder.Build())
{
host.Run();
}
}
Then create a function, please refer to this section.
Then add an appsettings.json file (Note: right click the file → select Properties → then set "Copy to Output Directory" to "Copy if newer"), add the AzureWebJobsStorage inside it:
{
"AzureWebJobsStorage": "{storage connection string}"
}
Please let me know if you still have more issues about that.
Related
I am experimenting with gRpc and have it running. I am using .net core 3.1. C# . I am now attempting to install it as a windows service. The machine is Win 10 Pro x64 .
I added the line as instructed to run it as a windows service...
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
//https://learn.microsoft.com/en-us/dotnet/architecture/grpc-for-wcf-developers/self-hosted
.UseWindowsService() // Enable running as a Windows service
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
I publish to a folder (I never have used publish before) and voila... there is the publish folder. I go to that folder and run (AS ADMINISTRATOR) installutil. Yes it found the utility as i used the full path. That path is
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\installutil.exe"
Is this correct version to run for .net core? Does that matter?
So I run installutil {full-path-to}\grpcservice1.exe
I get...
Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly
'file:///....\GrpcService1\GrpcService1\bin\Debug\netcoreapp3.1\publish\GrpcService1.exe'
or one of its dependencies. The module was expected to contain an
assembly manifest..
I can't figure out what I am doing wrong....
Suggestions? I just following the example.
TIA
installutil.exe looks for an Installer class marked with the RunInstallerAttribute set to true. It only works for Windows Services written with .NET Framework.
In the case of .NET Core, I'd recommend publishing your application and registering a new service using sc create/New-Service as you would in the case of any other executable.
There are also detailed docs in the .NET Core documentation in case you needed something more detailed.
I'm deploying a asp.net core 2.0 website to IIS 10.
I've made sure that my app is using the correct configuration for ISS in the program.settings file.
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
}
And in my startup.cs file:
public void ConfigureServices(IServiceCollection services)
{
services.Configure<IISOptions>(options =>
{
});
services.AddMvc();
}
Yet when I run dotnet website.dll from the command line I get the below error message shown in the command line window:
An assembly specified in the application dependencies manifest
(website.deps.json) was not found:
package: 'Microsoft.AspNetCore.Antiforgery', version: '2.0.1'
path: 'lib/netstandard2.0/Microsoft.AspNetCore.Antiforgery.dll' This assembly was expected to be in the local runtime store as the
application was published using the following target manifest files:
aspnetcore-store-2.0.3.xml
Based off the error message, i'm guessing Microsoft.AspNetCore.Antiforgery isn't being bundled when I publish since I do not receive this error when debugging.
How can I ensure that my app can find Microsoft.AspNetCore.Antiforgery when published to a live environment?
EDIT: This is a basic .net core website. No changes have been made to the standard project at this time apart from the above changes for deployment with IIS.
When I run the project from IIS instead of the command line I get a 502.5 error message.
I was able to fix this issue by updating the .net core runtime on the server to v2.0.3.
This issue occurs if
You have an existing server running v2.0.0 of the .net core runtime.
You create an app targeting v2.0.3 of the SDK
You publish the v2.0.3 app to a server running v2.0.0
The issue can be resolved by installing v2.0.3 of the runtime on the server. You can download the runtime from the microsoft site here https://www.microsoft.com/net/download/windows
If you are actually using this library, make sure that your *.csproj file has the corresponding explicit reference:
<PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="..." />
Then, play with the PublishWithAspNetCoreTargetManifest property to resolve the aforementioned issue with a mismatched manifest.
Check out the following threads to learn more about possible issues while its deployment:
An assembly specified in the application dependencies manifest (RhWeb.deps.json) was not found
published application is missing assembly (missing runtime store associated ...) [2.0.0-preview2-005905]
HTTP Error 502.5 - Microsoft.AspNetCore.Antiforgery.dll
I had this issue - simple workaround, actually install the NuGet package (I wasn't using it).
Microsoft.AspNetCore.Antiforgery
Published, deployed - fixed the issue.
In another case, when I published the project, a lot of the dlls weren't being placed in the publish folder - including Antiforgery. The below appears to force publishing to add all the required dlls.
Edit your projectname.json file to ensure PropertyGroup contains PublishWithAspNetCoreTargetManifest = false:
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>
Interested to know why the above works?!
This also problem happens if Antiforgery is called but Antiforgery is not installed.
Can be fixed by installing Microsoft.AspNetCore.Antiforgery by Nuget package manager.
I fixed this issue on my inhouse windowsserver with this solution
* go to netcore https://github.com/dotnet/core/tree/master/release-notes
* go to the lastest version of the core runtime 2.?
* download DotNetCore.2.0.6-WindowsHosting.exe in my case
https://github.com/dotnet/core/blob/master/release-notes/download-archives/2.0.6-download.md#net-core-runtime-only-installation
Install this on server and the error was solved for me. Hope this helps anyone.
Got this error after updating Microsoft.AspNetCore.All from v2.0.7 to v2.0.8 (latest at the time) and then publishing to a server that was running .NET Core Runtime v2.0.7 (latest at the time).
Downgraded Microsoft.AspNetCore.All back down to v2.0.7, re-published, and everything works.
If you publish the app as a self-contained ASP.NET Core 2.2 apps as per the linked screenshot (I don't have enough rep for inline image), it will fix this issue.
Self contained:
This can be set when editing your publish settings.
If this issue is related to your Razor mail template, you can add "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation". When I add, the problem is solved.
As stated in official document, I am trying to implement UseOwin in the Startup.cs.I am trying to use/port IAppBuilder (Microsoft.Owin.Builder.AppBuilder) inside IApplicationBuilder (Microsoft.AspNetCore.Builder.IApplicationBuilder). I had legacy code written using IAppBuilder running fine on .Net Framework 4.5.
I have seen couple of examples about using IAppBuilder in IAplicationBuilder e.g. example 1 example 2. These attempts were about .netcore 1.1 and not .net core 2.0. May be this is the reason i am unable to port.
Please share your thoughts whether i am trying to achieve something not possible at the moment in .net core 2.0 or there is some error in my code.
Note:
I am using dotnetcore 2.0 with Visual Studio 2017
Error
I am getting following error.
return owinAppBuilder.Build,
Task>>(); TypeLoadException: Could not load type
'System.Security.Cryptography.DpapiDataProtector' from assembly
'System.Security, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'.
My attempt
app.UseOwin(setup => setup(next =>
{
var owinAppBuilder = new AppBuilder();
var aspNetCoreLifetime =
(IApplicationLifetime)app.ApplicationServices.GetService(typeof(IApplicationLifetime));
new AppProperties(owinAppBuilder.Properties)
{
OnAppDisposing = aspNetCoreLifetime?.ApplicationStopping ?? CancellationToken.None,
DefaultApp = next,
AppName = "test"
};
// Only required if CORS is used, configure it as you wish
var corsPolicy = new System.Web.Cors.CorsPolicy
{
AllowAnyHeader = true,
AllowAnyMethod = true,
AllowAnyOrigin = true,
SupportsCredentials = true
};
//corsPolicy.GetType()
// .GetProperty(nameof(corsPolicy.ExposedHeaders))
// .SetValue(corsPolicy, tusdotnet.Helpers.CorsHelper.GetExposedHeaders());
owinAppBuilder.UseCors(new Microsoft.Owin.Cors.CorsOptions
{
PolicyProvider = new CorsPolicyProvider
{
PolicyResolver = context => Task.FromResult(corsPolicy)
}
});
PublicClientId = "self";
OAuthAuthorizationServerOptions OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new Microsoft.Owin.PathString("/Login"),
Provider = new MyServiceProvider(PublicClientId),
AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(60),
AllowInsecureHttp = true,
RefreshTokenProvider = new MyRefreshTokenProvider(),
};
owinAppBuilder.UseOAuthBearerTokens(OAuthOptions);
//owinAppBuilder.UseTus(context => new DefaultTusConfiguration
//{
// // Excluded for brevity, use the same configuration as you would normally do
//});
return owinAppBuilder.Build<Func<IDictionary<string, object>, Task>>();
}));
Microsoft.Owin and related packages do not have targets for .NET Core, no for .NET Standard. All they have is dlls targeting full .NET. You can reference such libraries from your project targeting .NET Core, but they are not guaranteed to work, as you see yourself, because API (set of classes\methods\signatures) of full .NET and .NET Core are different. Visual Studio even will show a warning when you are doing that, for example:
Package 'Microsoft.Owin 3.1.0' was restored using
'.NETFramework,Version=v4.6.1' instead of the project target framework
'.NETCoreApp,Version=v2.0'. This package may not be fully compatible
with your project.
There is Microsoft.AspNetCore.Owin package and you can use OWIN middleware in .NET Core app as your first link describes, but almost all it provides is UseOwin extension method. There is no AppBuilder type there and so on, and there are no Microsoft.AspNetCore.Owin.Cors packages or similar. So you have to either implement all that yourself (no reason to, because you can use the same functionality provided by asp.net core framework) or wait for OWIN packages that target .NET Standard\Core and do that (didn't check, maybe they even exist already).
So, your code uses packages which are indeed not compatible with your target framework, as exception you have at runtime shows. So another answer (for some reason downvoted) is technically correct.
If you still want to use those packages reliably - you need to target full .NET Framework and not .NET Core. To do that, open your .csproj file and change
<TargetFramework>netcoreapp2.0</TargetFramework>
To some .NET framework version that supports .NET Standard 2.0, for example:
<TargetFramework>net47</TargetFramework>
Then go to nuget package manager and, if you have microsoft.aspnetcore.all package (or other packages targeting .NET Core) - uninstall it, you don't need it anyway. Then install Microsoft.AspNetCore package and all other asp.net core packages you need (if not installed already). Rebuild, run and it will work just fine.
That works because all (most?) AspNetCore packages target .NET Standard, not .NET Core, and you can use them in projects targeting full .NET Framework.
Note that by doing that you have asp.net Core project, but not on .NET Core, with all consequences that come from that (cannot run with dotnet run, on linux need to run with mono, and so on).
The Microsoft.Owin components will not work on dotnet core 2.0, they only work on .NET 4.5+
I've been developing an ASP.NET Core web app, based largely on the MVC template provided in Visual Studio 2017 RC2. It runs just fine in local debug mode, but when I try to publish it to an Azure hosted web app, I get this error:
An error occurred while starting the application.
.NET Core X86 v4.1.1.0 | Microsoft.AspNetCore.Hosting version
1.1.0-rtm-22752 | Microsoft Windows 6.2.9200
I've tried setting stdoutLogEnabled="true" in the web.config file, but it seems to have no effect, the error is the same.
Update:
With some help I managed to retrieve the log, and it says:
Application startup exception: System.TypeLoadException: Could not load type 'System.IO.File' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
at Microsoft.Extensions.DependencyModel.FileWrapper.OpenRead(String path)
at Microsoft.Extensions.DependencyModel.DependencyContextLoader.LoadEntryAssemblyContext(IDependencyContextReader reader)
at Microsoft.Extensions.DependencyModel.DependencyContextLoader.Load(Assembly assembly)
at Microsoft.Extensions.DependencyModel.DependencyContext.Load(Assembly assembly)
at Microsoft.AspNetCore.Mvc.Internal.DefaultAssemblyPartDiscoveryProvider.DiscoverAssemblyParts(String entryPointAssemblyName)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddMvc(IServiceCollection services)
at Bla.Api.Startup.ConfigureServices(IServiceCollection services) in C:\Users\user\Source\Workspaces\Bla\Bla.Api\src\Bla.Api\Startup.cs:line 73
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
Hosting environment: Production
Content root path: D:\home\site\wwwroot
Now listening on: http://localhost:1264
Application started. Press Ctrl+C to shut down.
The line of code it refers to at line 73 is:
services.AddMvc();
Update:
My global.json file looks like this (where Bla.Api is the name of the project, and the file sits in the solution root folder).
{
"projects": [ "Bla.Api" ],
"sdk": {
"version": "1.1.0"
}
}
Since many different problems can cause this error page, I can strongly recommend the following in order to determine the root cause quickly and easily, without wrestling Azure (or any server/platform for that matter) to get logs.
You can enable extremely helpful developer friendly error messages at startup by setting the .UseSetting("detailedErrors", "true") and .CaptureStartupErrors(true) actions in your Program.cs file.
For ASP.NET Core 1.x
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseSetting("detailedErrors", "true")
.UseIISIntegration()
.UseStartup<Startup>()
.CaptureStartupErrors(true)
.Build();
host.Run();
}
(2018/07) Update for ASP.NET Core 2.1
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.CaptureStartupErrors(true)
.UseSetting("detailedErrors", "true")
.UseStartup<Startup>()
.Build();
}
These settings should be removed as soon as your troubleshooting is complete so as not to expose your application to malicious attacks.
Connect via an sftp client and delete everything in the site/wwwroot folder manually. Republish
I have had nothing but problems since I migrated an application I have hosted on Azure to .net core from MVC 4.
At one point a few weeks ago I was unable to get a project to run after a successful publish. I even tried twice to delete the entire App Service profile and recreate it with the same name. However when I appended a '2' to the App Service name (to create a never before used app service) publishing the exact same project with 0 changes worked perfectly. What exactly does a delete do if I can publish successfully to a new app service but not a deleted and recreated one? Remove Existing Files At Destination was checked in each publish, that didn't do anything either.
I had the same error today as pictured in the OP in my #2 site. It occurred after attempting to update a number of asp nuget packages and re-deploy. Really not wanting to have to move on to iteration myApp3 of my app service, I decided to use the FTP information provided in the azure overview page. I navigated to Site/wwwroot and deleted everything inside from the FTP client. I then published the application, and it worked. I can only conclude that the 'Delete' checkbox doesn't work properly.
Thanks everyone for your suggestions. The only thing that worked in the end though is deleting that Azure web app that I couldn't publish to, and creating a brand new one. I guess maybe some of the .dlls from the previous runtime environment were still hanging around or not being updated... Whatever it was, re-creating it worked. Hopefully I don't get this error again though, because you can't really do this kind of stuff in production.
Making changes to the global.json file seemed to have no effect.
Creating an entirely new API from a template didn't help either, the issue was with the Azure Web App itself, as everything was running fine locally.
Another very helpful tip was to add logging (and the "logs" file in the root) as per the other answer. That at least pointed me in the right direction. Also checking your runtime with dotnet --version.
Again thanks for everyone's help!
I've got the same problem. Just not deployed at Azure, I'm using my local machine as server and host it in IIS.
An error occurred while starting the application.
.NET Core X64 v4.1.1.0 | Microsoft.AspNetCore.Hosting version 1.1.1 | Microsoft Windows 10.0.14393 | Need help?
And this was solved by changing web.config.
First set stdoutLogEnabled = "true"
Then make sure stdoutLogFile=".\logs\stdout" /> this folder exists.
And then restart IIS, you can find the real problem in log file.
DELETE all existing dll from wwwroot/your_application_folder, then copy all of the publish output files&folders.
The problem occurs when the NUGETS update it self. If you don't clean the existing files under wwwroot/your_application_folder IIS gives the error above.
Clean and rebuild fixed everything.
Question is probably duplicated - please refer to ASP.NET Core hosting - 500 internal server error.
Quick answer:
You need to set: stdoutLogEnabled="true" and stdoutLogFile=".\logs\stdout". Also, you need to create logs folder manually.
In my case, it was because I was trying to publish user secrets for use with Fabook OAuth. I know that's a very situational specific answer, but OAuth seems pretty common these day. User Secrets, it turns out, are not meant to be published. Who knew.
So to test this I temporarily changed the following code in startup.cs. This data should be not hard coded as a part of best practice, as it would end up in clear text in source control.
Before
app.UseFacebookAuthentication(new FacebookOptions()
{
AppId = Configuration["Authentication:Facebook:AppId"],
AppSecret = Configuration["Authentication:Facebook:AppSecret"]
});
After
app.UseFacebookAuthentication(new FacebookOptions()
{
AppId = "0000000000000", // your value
AppSecret = "0000000000000000000000000000000" // your value
});
Then it worked.
In My case, that was because I was trying to get a some data in Startup, and dbcontext was not updated in production environment.
Changed my ConnectionString to Production and runned Update-Database, and problem solved.
In my case there was a directory named Resources that was missing in app directory.
Within a .netCore library I want to connect to an Oracle database. Is there any way I can do that yet?
I have tried the suggestions on another SO post, but it doesn't work, perhaps removed since? As you can see in my project.json, I'm trying to use "net461".
I'm currently trying using Oracle.ManagedDataAccess.Client via old fashioned ADO.Net. I also know that Oracle haven't bought out a .netCore connector yet. But even there I can't get it to work, it struggles to get the System.Data included, it errors whenever I try to add it.
My project.json looks like this:
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6.0",
"Oracle.ManagedDataAccess": "12.1.24160719",
},
"frameworks": {
"netstandard1.6": {
"imports": [
"dnxcore50",
"net461"
]
}
}
}
This is how I was trying to do it at the moment.
using Oracle.ManagedDataAccess.Client;
public class MyRepository
{
public string GetServerVersion()
{
var _db = new OracleConnection("User Id=myUser;Password=myPassword;Data Source=MyOracleConnection");
var serverVersion = _db.ServerVersion;
return serverVersion;
}
}
However the above doesn't compile as it doesn't have System.Data, which I'm struggling to import.
I'm not entrenched on any particular way of doing it, I just want the best reasonable option at this point in time.
Beta release .Net Core Managed driver released by Oracle at the end of January 2018 http://www.oracle.com/technetwork/topics/dotnet/downloads/net-downloads-160392.html.
Supported platfom mentionet in doc is now Win and Linux.
Nuget: https://www.nuget.org/packages/Oracle.ManagedDataAccess.Core
Other old alternatives with standart/instant Oracle clients :
for .Net Core 2.0 I recomend to use ericmend oracleClientCore-2.0 : https://github.com/ericmend/oracleClientCore-2.0. Nuget: dotNetCore.Data.OracleClient I used it succesfully in Win and Linux platform. There is my small sample
alternativelly System.Data.OracleClient works for 2.0 too - see #Owen post. But I test it only in Win platform
for .Net Core >= 1.0 you can use unofficial LinqDan Oracle client for .NET Core based on Mono's Oracle client https://github.com/LinqDan/oracleclientcore
Nuget: Mono.Data.OracleClientCore.
my TestCore.csproj for last alternative :
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Mono.Data.OracleClientCore" Version="1.0.0" />
</ItemGroup>
</Project>
My program.cs:
using System;
using System.Data.OracleClient;
namespace TestCore
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Starting.\r\n");
using (var _db = new OracleConnection("User Id=myUser;Password=myPassword;Data Source=MyOracleConnection"))
{
Console.WriteLine("Open connection...");
_db.Open();
Console.WriteLine( "Connected to:" +_db.ServerVersion);
Console.WriteLine("\r\nDone. Press key for exit");
Console.ReadKey();
}
}
}
}
Oracle published the official Data Provider for .NET Core on nuget.
Here is a basic example to show how to use it:
using Oracle.ManagedDataAccess.Client;
public void Execute(string queryString, string connectionString)
{
using (OracleConnection connection = new OracleConnection(connectionString))
{
OracleCommand command = new OracleCommand(queryString, connection);
command.Connection.Open();
command.ExecuteNonQuery();
}
}
Basically you can use it exactly like the official .NET System.Data.SqlClient (easy to find online tutorials for this) and just replace everywhere in the code SqlConnection with OracleConnection and SqlCommand with OracleCommand.
Oracle plans to certify ODP.NET, Managed Driver on Microsoft .NET Core around the end of calendar year 2017.
Oracle intends to support managed ODP.NET on .NET Core on Windows operating systems and Oracle Linux.
Managed ODP.NET may support additional operating systems. Oracle will continue to evaluate support for
other Linux distributions and will announce additions to the certification list at a future time.
Oracle does not plan to certify on earlier versions than Microsoft .NET Core 2.0. .NET Core 2.0 contains
numerous features that make managed ODP.NET certification possible on the framework
From this article :http://www.oracle.com/technetwork/topics/dotnet/tech-info/odpnet-dotnet-core-sod-3628981.pdf
Updated: Beta released ODP.NET Core
If you are using oracle database with .NET core then need to install few nuget packages.
Microsoft.EntityFrameworkCore
Oracle.EntityFrameworkCore
Oracle.ManagedADataAccess.Core
After this need to write some code in the configureServices method of startup class.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<OracleDbContext>(options=>options.UseOracle(Configuration.GetConnectionString("OracleConnection")));
}
OracleDbContext class is inherting from the DbContext class and OracleConection connection string is set up in the appSettings.json file.
OracleDbContext.cs
public class OracleDbContext : DbContext
{
public OracleDbContext(DbContextOptions options):base(options){}
}
appSettings.json
{
"ConnectionStrings":{
"OracleConnection":"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=
(PROTOCOL=TCP)(HOST={url of your database})(PORT={port})))(CONNECT_DATA=
{name of your database for ex: SID})));User Id={user id};password=
{password}:"
}
}
Values in bracket {} needs to be replaced. This connection string is used when the database is on the server, not locally.
As mentioned in other answers, Oracle has not yet released a package for their Managed Client, but is planned for later this year.
However, as of the release of .NET Standard 2.0, the System.Data.OracleClient library has been updated (available via NuGet). Obviously this is not an ideal solution since that library is obsolete, but it does give you something to work with - and you can just write a wrapper and swap it out for the official Oracle library when it is released.
Add appsettings.json to project (output dir: copy always). fill connection strings:
{
"ConnectionStrings": {
"connection-db": "Data Source=192.168.1.3:1521/ORACLEVM;User
Id=userId;Password=123;Validate Connection=true;"
}
}
Open Manage Nuget Packages in project, add these packages:
Microsoft.Extensions.Configuration.Json (to use configuration manager in .net core)
Oracle.ManagedDataAccess.Core (.net core version of oracle data access client)
static void Main(string[] args)
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json");
var configuration = builder.Build();
var connectionString = configuration.GetConnectionString("connection-db");
using (OracleConnection connection = new OracleConnection(connectionString))
{
var command = new OracleCommand("INSERT INTO ..", connection);
connection.Open();
command.ExecuteNonQuery();
}
}
You should delete "dnxcore50" (This means your project is not a pure .net core application any more) from project.json under frameworks node and try again. As far as I know you can not connect to oracle via .net core FOR NOW, maybe checking this link can helpful
Based on Oracle .NET team They have released a new beta ODP.NET Core;
You can also find it here
finally devart's dotConnect for Oracle support .net core since version "9.4.280".
We have done this by setting up an oracle linked server and using stored procedures that make calls to the Oracle linked server from SQL server. You might try that. You can use Openquery or Exec .. At [likedserver] to make the querys execute on the Oracle side.