How to upgrate to EntLib 5 (from 1.1) IStorageProviderReader doesn't exist - enterprise-library

Yes, I know. Looks like my new company is still using EntLib 1.1!!!!!
I am trying to upgrade the both client and server side apps to use new EntLib 5 libraries.
First thing I have come across is that we use custom Storage Provider by inheriting IStorageProviderReader as we store the configs in separate system.
Config looks like this:
<enterpriselibrary.configurationSettings applicationName="Archiving.Services" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/configuration">
<configurationSections>
<configurationSection xsi:type="ReadOnlyConfigurationSectionData" name="dataConfiguration" encrypt="false">
<storageProvider xsi:type="CustomStorageProviderData" name="Profile Service Storage Provider" type="Our.Custom.Provider, provider.dll"/>
<dataTransformer xsi:type="XmlSerializerTransformerData" name="Xml Serializer Transformer">
<includeTypes/>
</dataTransformer>
</configurationSection>
What's the alternative class/interface I can use to provide my own custom storage provider so that override and all *.config files from our custom provider?

This is going way back. I believe that with the release of Enterprise Library 2.0 the original Configuration Application Block was removed. This was because .NET 2.0 added native configuration functionality (very similar to the Enterprise Library functionality).
What you should do is to migrate your Enterprise Library providers to use the functionality available in the System.Configuration Namespace.

Related

Adding an AuthorizationHandler via config

In WCF, you can add an authorization policy through the web.config by using the serviceAuthorization node in a service behavior. Is there a way to include an AuthorizationHandler in .NET Core WebAPI via config?
To be clear, I'm trying to replace this line in Startup.cs with something in the web.config:
services.AddSingleton<IAuthorizationHandler, MyAuthorizationHandler>();
web.config is only used for IIS specific config. Because of .net-core's cross platform nature they ditched coupling to web config for application configuration.
A web.config file is required when hosting the app in IIS or IIS Express. Settings in web.config enable the ASP.NET Core Module to launch the app and configure other IIS settings and modules.
Reference Configure an ASP.NET Core App: The web.config file
Startup is your entry point into the application where you can have some settings in the json file and have your code add/update the configuration based on that.
My thinking is that it would save having to recompile every time you want to add something because configuration options allows you to Reload configuration data with IOptionsSnapshot
Requires ASP.NET Core 1.1 or later.
IOptionsSnapshot supports reloading options with minimal processing overhead. In ASP.NET Core 1.1, IOptionsSnapshot is a snapshot of IOptionsMonitor<TOptions> and updates automatically whenever the monitor triggers changes based on the data source changing. In ASP.NET Core 2.0 and later, options are computed once per request when accessed and cached for the lifetime of the request.
Your authorization handler(s) would depend on the options and perform its function based on the configurations provided.

Is there an alternate to Web.config Transormations in Asp.NET Core appsettings.json?

Is there an alternate to Web.config Transormations in Asp.NET Core appsettings.json?
I would like to change connection strings and other settins when deploying to staging.production server from VS.
First of all, keep in mind, that
ASP.NET Core’s configuration system has been re-architected from previous versions of ASP.NET, which relied on System.Configuration and XML configuration files like web.config. The new configuration model provides streamlined access to key/value based settings that can be retrieved from a variety of sources.
To work with settings in your ASP.NET application, it is recommended that you only instantiate a Configuration in your application’s Startup class. At its simplest, Configuration is just a collection of sources, which provide the ability to read and write name/value pairs.
ASP.NET Core provides built-in support for JSON, XML, and INI configuration files as sources and allows to choose source accordinly to current environment. The ASPNETCORE_ENVIRONMENT environment variable is used to setup/determine the current environment. Predefined values are Development, Staging, Production, but can be any custom also.
Lets say you want to use JSON file (named appsettings.json for convention) for storing connection string. What you need to do is to create a separate appsettings.{EnvironmentName}.json files (for each environment you have) like:
appsettings.Development.json
appsettings.Staging.json
appsettings.Production.json
and load one of them accordingly to environment:
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
Read more about all of this in the “Configuration” chapter and the “Working with multiple environments” chapter of the ASP.NET Core documentation.
Yes, you must use environment variables on the target system.
ASP.NET Core references a particular environment variable, ASPNETCORE_ENVIRONMENT to describe the environment the application is currently running in. This variable can be set to any value you like, but three values are used by convention: Development, Staging, and Production. You will find these values used in the samples and templates provided with ASP.NET Core.
Determining the environment at runtime
The IHostingEnvironment service provides the core abstraction for working with environments. This service is provided by the ASP.NET hosting layer, and can be injected into your startup logic via Dependency Injection. The ASP.NET Core web site template in Visual Studio uses this approach to load environment-specific configuration files (if present) and to customize the app’s error handling settings. In both cases, this behavior is achieved by referring to the currently specified environment by calling EnvironmentName or IsEnvironment on the instance of IHostingEnvironment passed into the appropriate method.
https://docs.asp.net/en/latest/fundamentals/environments.html

AspNet Core Consuming WebService (VS2015)

In my AspNet Core project I need to consume a SOAP/WSDL WebService. I am using VS2015 and have made a non-aspnet core project to test the webservice (went fine), but with AspNet Core, I cannot seem to find a way to make this happen. It looks like SOAP webservice isn't supported (yet?) but if that is the case, is there a different way to consume a soap webservice?
I am already using the net461 framework so I can use the normal .NET libraries, but VS2015 doesn't expose the “Add Service Reference” menu option.
Find this similar question. I have not implemented/verified/tested it but hopefully yo can find some guidance. The sample is using the prior version of AspNet Core (AspNet 5)
ASP.NET 5 add WCF service reference
https://learn.microsoft.com/en-us/dotnet/core/additional-tools/wcf-web-service-reference-guide
See if this helps. In VS 2017, I am able to add the service reference from connected services in a .net core project. You might need to install "WCF Service Reference Provider" Extension.

how to solve SOAP services issue with portable class library?

i have an issue using SOAP services from portable class library.
once i add the service refrence configuration file created empty and calling any operation form Windows Phone or Windows store app project returns null value.
However if i added the refrence to WP or W8 project directly configuration file is npot empty and operations return data
any reason for that ?
It is the same as in full .NET. If you call a web service, the configuration file is searched for in the calling assembly, that is in your case the WP8 project.
You have two options. One is to copy the relevant configuration from app.config in the PCL to the WP8 porject or to create the web service configuration completely in code in your PCL so no config file anywhere is needed.

Microsoft Sync Framework with MongoDB

we are developing a multiplateforme mobile application thats support synchronization with NoSQL backend, we are looking if Microsoft Sync Framework 4.0 CTP can be used to solve all synchronization problems using a non-microsoft backend,
Sync Framework 4.0 allow several devices on any plateforme to achive synchronization tasks by exposing an oData service, this can be done by using Sync Framework Toolkit, but use SQL Server or SQL Azure as backend on the service side,
the application we are developing should use NoSQL database server (MongoDB) on its server side and I realy dont know if Microsoft Sync Framework could be used with this DBMS and how it should be done,
if someone have achieved this by customizing Microsoft Sync Framework provider please share your experience, links or any helpful things,
thanks in advance,
there is no out-of-the-box sync provider for MongoDB, so you will have to write your own.
assuming you can write your own, you will have to modify the Sync Toolkit server side component to replace the SqlSyncProvider with your custom MongoDB provider.
I suggest you check out the licensing of the Sync Framework Toolkit as well. if I remember it right, the client components is on Apache license but the server side is on MSPL.
#Mrinal :
I started writting a Microsoft Sync Framework MongoDB Provider but i realized later that i had to implement a good part of Sync Framework, so I have removed all dependencies between Sync Framework and Sync Framework Toolkit to take juste the infrastructure part of Sync Framework Toolkit and i implemented my own synchronization logic inside, i've also updated the client side to use my NoSQL To SQL ORM to store data on Client-SQLite db.
I suggest you to use SyncFoundation if you have no time to do all this tasks, Sync foundation is a lightweight version of Sync Framework but more flexible if you have to use a non microsoft backend, the home page of sync foundation is (https://github.com/mschoneman/SyncFoundation).