1

Below is is my wcf Web.config file code which i want to use in corewcf projects

<?xml version="1.0"?>
<configuration>
    <configSections>
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
    </configSections>
    <system.serviceModel>
        <bindings>
            <customBinding>
                <binding name="HubBinding" openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00">
                    <security defaultAlgorithmSuite="Basic256Sha256Rsa15"/>
                    <textMessageEncoding messageVersion="Default"/>
                    <httpsTransport maxReceivedMessageSize="1073741824"/>
                </binding>
                <binding name="CustomBinding_IProductServiceMahV20181" openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00">
                    <security/>
                    <textMessageEncoding/>
                    <httpsTransport/>
                </binding>
                <binding name="CustomBinding_IReportingServiceMahV20181">
                    <security/>
                    <textMessageEncoding/>
                    <httpsTransport/>
                </binding>
            </customBinding>
        </bindings>
        <services>
            <service behaviorConfiguration="Behavior_M_1126_1_certification" name="VeriShieldProxy.Wcf.ProductService_M_1126_1_certification">
                <endpoint address="" binding="customBinding" bindingConfiguration="HubBinding" name="ProductService_M_1126_1_certification" contract="VeriShieldProxy.Wcf.IProductServiceMahV20181"/>
            </service>
            <service behaviorConfiguration="Behavior_M_1126_1_certification" name="VeriShieldProxy.Wcf.ReportingService_M_1126_1_certification">
                <endpoint address="" binding="customBinding" bindingConfiguration="HubBinding" name="ReportingService_M_1126_1_certification" contract="VeriShieldProxy.Wcf.IReportingServiceV20161"/>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="Behavior_M_1126_1_certification">
                    <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                    <serviceCredentials>
                        <serviceCertificate findValue="83796fd9d459e9ea7aa6360a411dcbe9e88dabcd" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint"/>
                    </serviceCredentials>
                    <serviceSecurityAudit auditLogLocation="Application" serviceAuthorizationAuditLevel="Failure" messageAuthenticationAuditLevel="Failure" suppressAuditFailure="true"/>
                </behavior>
                <behavior name="Behavior_M_1126_2_production">
                    <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                    <serviceCredentials>
                        <serviceCertificate findValue="c541f3975f595778c35c52f670d2940a7893efgh" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint"/>
                    </serviceCredentials>
                    <serviceSecurityAudit auditLogLocation="Application" serviceAuthorizationAuditLevel="Failure" messageAuthenticationAuditLevel="Failure" suppressAuditFailure="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>

Tried below code in Program.cs file to use web.config setting into corewcf projects

Getting below error enter image description here

System.TypeLoadException: 'Could not resolve type 'VeriShieldProxy.Wcf.IProductServiceMahV20181' in assembly 'CoreWCF.ConfigurationManager, Version=1.5.0.0, Culture=neutral, PublicKeyToken=64a15a7b0fecbbfb'.'


var builder = WebApplication.CreateBuilder();

builder.Services.AddServiceModelServices();
builder.Services.AddServiceModelConfigurationManagerFile("Web.config");
builder.Services.AddServiceModelMetadata();
builder.Services.AddSingleton<IServiceBehavior, UseRequestHeadersForMetadataAddressBehavior>();

var app = builder.Build();

app.UseServiceModel(serviceBuilder =>
{
    serviceBuilder.AddService<Service>();
    serviceBuilder.AddServiceEndpoint<Service, IService>(new BasicHttpBinding(BasicHttpSecurityMode.Transport), "/Service.svc");
    serviceBuilder.AddService<VeriShieldProxy.Wcf.ProductServiceV20181>();
    serviceBuilder.AddServiceEndpoint<VeriShieldProxy.Wcf.ProductServiceV20181, VeriShieldProxy.Wcf.IProductServiceV20181>(new BasicHttpBinding(BasicHttpSecurityMode.Transport), "/ProductServiceV20181.svc");
    var serviceMetadataBehavior = app.Services.GetRequiredService<ServiceMetadataBehavior>();
    serviceMetadataBehavior.HttpsGetEnabled = true;
});

app.Run();
1
  • Many of the packages in the ASP.NET Framework are not available in ASP.NET Core. If there are some configurations in web.config that cannot be used by core, the default configuration is usually used or an error is reported. You can read this document. Commented Apr 29, 2024 at 5:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.