Reading launchSettings.json in .NET Core project? - json

I have finally started my transition to .NET Core and need some quick help with getting to the environmentVariables section of the launchSettings.json file. Googling indicates pretty much all NetCore is currently ASP.NET Core whereas I'm currently spiking with libraries and console apps myself.
Is there no API for this?

launchSettings.json is a configuration file on how to launch ASP.NET Core applications. If you're looking for a .NET Core alternative to app.config for a console application, have a look at appSettings.json.
A (simple) example can be found here Using strongly typed configuration in .NET Core console app

Related

What is the best solution to receive HTTP JSON Request in a PRISM WPF application context?

I´ve migrated a Prism WPF Application to .NET Core 3.1 but one project uses a WCF-Service which receives Http-Json-Post-Requests and I wasn´t able to find an alternative working in .NET Core 3 or .Netstandard...
In the previous .NET Framework version WCF calls published events by the IEventAggregator to execute EventHandlers in decoupled Prism modules...I tried to add a .NET Core Web Api project handling my HTTP requests but I could not host it in the Prism application or add my UnityContainer to the .NET Core Web Api project...does anyone have an idea how I can replace my WCF project with a .NET Core 3 project ?
Problem solved by self hosting ASP.NET Core in a separate netstandard2.1 project, registering the class containing the WebHost to the UnityContainer of the PRISM application and injecting the UnityContainer to be used by the WebHost as IServiceCollection.

installing asp.net mvc web application on mac, but getting these error

Have attached an image of all the packages and references I am trying to build an ASP.NET MVC Web Application on Visual Studio 2019 Community for Mac, but I am getting these errors. I tried a lot to resolve these, but couldn't find any answers online. It would be great if someone can help me figure these out.
This project was previously developed and build on Windows, but the same project does not build properly on Mac, and now I am getting these errors. One reason could be ASP.NET having different frameworks, but not sure which framework would be suitable for these packages.
Adding another picture, I have updated the ASP.NET framework to 4.7.2 from version 2.0 click to view image
And I left with very few errors only "System.Web.Entity" picture attached
System.Web.entity is for .NET Framework and Asp.Net MVC project is not cross-platform.
So,it's not possible to build ASP.NET MVC projects on the Mac that aren't based on .NET Core or Mono.ASP.NET 4.x is not something officially supported like ASP.NET Core on macOS.
If you want to use ASP.NET 4.x, stick to Windows. If you want to use macOS and VS for Mac, use ASP.NET Core. There is almost no gray area in between to discuss.
Another suggestion is that you could use virtual machine to run windows inside Mac.
Refer to Is it possible to develop ASP.NET MVC applications in Visual Studio for Mac?

SSIS C# Script using Google.Apis.Auth.OAuth2;

I made a C# Script in SSIS pulling data from GA API. On Monday, Google closed the access to the api via basic authentication
AnalyticsService service = new AnalyticsService(Dts.Variables["CONFIG_GA_PROJECT"].Value.ToString());
service.setUserCredentials(username, pass);
=> Got 404 error
So I want to move to the following security implementation : Accessing older GData APIs (Spreadsheet API) using OAuth 2 and a service account
The problem is : seems like we can't use nuget installation in SSIS Script as dll has to be pushed in the GAC.
I tried using : How to install a DLL to the GAC on Windows Server 2012 using only PowerShell (without having to install SDK or Visual Studio) but didn't work...
Is anyone found a way to use Google.Apis.Auth.dll in a SSIS C# Script task ?
The problem you are having is due to the fact that the Google .net client library aren't strong name signed, so they cant be pushed to GAC. Also remember that the current Google .net client only works with .net 4 and .net 4.5 so you are going to be locking out the older versions of SSIS I think.
This is reason I didn't use them in my Google Analytics Custom SSIS Data Reader and Connection Manager which uses Oauth2.
Options:
Strong name sign the Client library yourself. code here
Wait for the strong name signed version of the library to be released. I hope its done soon. Strong Naming in binaries #238
Do what I did and code it all yourself with out the Client library, this allows you to code for .net 3.0 and support SQL server 2005 - 2012 like mine.
I hope this helps. The one I made is free for download you are welcome to have a look Data Reader for Google Analytics

There was a mismatch between the processor architecture

I am currently building a Windows store application using visual studio 2012 in 4.5.1 framework
I have added the reference PresentationCore.dll for the 'bitmapImage' and i am confronted by an error saying 'There has been a mismatch between the processor architecture of the project being build MSIL & processor architecure of presentationCore'
I have tried the method concerning the use of the configuration manager and still seems to not work, would anybody be able to give me any in sight?
PresentationCore.dll is from the Windows Presentation Foundation. You cannot add a WPF DLL to a Windows Store app as you will be mixing between .NETFramework (desktop) and .NETCore (WinRT).

Unity 2.0 for shared application configuration possible?

I'm struggling with trying to create a shared configuration file for a web project and 2 dll projects. From what I can tell StructedMap can be used for configuration settings. Anyone successfully use Unity 2.0 to do the same?
Ended up using a custom configuration. Phil Hack has a great tutorial here.