Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not load type 'System.ServiceModel.Description.MetadataConversionError #4147

Open
StephenBonikowsky opened this issue Jan 31, 2020 · 25 comments
Assignees
Labels
customer assistance Help customers with questions regarding usage of WCF features.

Comments

@StephenBonikowsky
Copy link
Member

@HASSEN-MEDDEB-ATOS commented on Thu Jan 30 2020

Hello again,

i have migrated my project from .NET Framework to .NET core. i have changed this line from

  sp.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
to

 sp.ServiceConfiguration.CurrentServiceEndpoint.EndpointBehaviors.Add(new ProxyTypesBehavior());
because we used System.ServiceModel.Primitives 

but it return Exception: Could not load type 'System.ServiceModel.Description.MetadataConversionError' from assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Thanks for all helps

Cordially


@maryamariyan commented on Thu Jan 30 2020

cc: @dotnet/dotnet-wcf


@StephenBonikowsky commented on Thu Jan 30 2020

@HASSEN-MEDDEB-ATOS The types you mentioned belong to WCF. (https://github.com/dotnet/wcf)

Not all of WCF from the full framework is available in WCF Core. We are still adding support for many features but some are not yet available and others we will not be able to support. Server side APIs will not be supported in WCF Core only Client side APIs.

System.ServiceModel.Description.MetadataConversionError is not currently supported. You can check any API in the https://apisof.net/ tool to see where it is supported.

@mconnew Is this API related to server side stuff or could it be added to the WCF Core public surface area. Looks like it was at least partially implemented in WCF Core although I don't see any references to it.


@HASSEN-MEDDEB-ATOS commented on Fri Jan 31 2020

Helle @StephenBonikowsky ,

Thanks for your answer.
I can't undestrand somthing, System.ServiceModel is deprecated in both .NET Standard and .NET Core. I have added the new package "System.ServiceModel.Primitives" i can see that System.ServiceModel has been added in the reference with version "4.7.0". the question, why i get System.ServiceModel, Version=4.0.0.0 not load ? even so i have installed the version 4.7.0

Cordially


@StephenBonikowsky commented on Fri Jan 31 2020

On full framework System.ServiceModel.dll contains most of the WCF implementation.

WCF Core works differently, all the implementation code lives in the System.Private.ServiceModel package but that package cannot be referenced directly. Instead we have 5 Façade packages in which the ref assembly has a list of publicly accessible APIs and the lib assembly type-forwards to the implementation in System.Private.ServiceModel.

Because the full framework supports netstandard2.0 as does WCF Core, we have included in our System.Primitives.ServiceModel package a Façade assembly called System.ServiceModel.dll for the scenario where you build your application on the full framework targeting netstandard2.0 and then run it on WCF Core. In that case the System.ServiceModel.dll Façade will type-forward to the WCF Core implementation in System.Private.ServiceModel.dll. It only knows about types that are supported on both full framework and core as per netstandard2.0.

So back to your error. You are trying to load a type that is not supported in WCF Core and the System.ServiceModel Façade knows nothing about it.

Since this is a WCF issue, I amgoing to move it to the WCF Repo.

@HASSEN-MEDDEB-ATOS
Copy link

HASSEN-MEDDEB-ATOS commented Feb 3, 2020

Any update for this issue please ? I have tried many other solution without success

@StephenBonikowsky
Copy link
Member Author

@HASSEN-MEDDEB-ATOS I'm not sure what update you are asking for, I mentioned in my previous post that you are trying to use a type that is not supported in WCF Core.

@HASSEN-MEDDEB-ATOS
Copy link

Hello,
is there any possibility to connect to dynamics without using System.ServiceModel.Description.ClientCredentials, i tried to use ADAL but i can't combined ADAL with OrganizationServiceProxy

System.ServiceModel.Description.ClientCredentials cc = new ClientCredentials();
                ClientCredentials cd = null;

                cc.UserName.UserName = Login;
                cc.UserName.Password = MDP;

                // On se connecte
                sp = new OrganizationServiceProxy(OrganizationUri, null, cc, cd);
                sp.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

Cordially

@StephenBonikowsky
Copy link
Member Author

@mconnew Do you have any suggestions?

@HASSEN-MEDDEB-ATOS
Copy link

Hi again,

The OrganizationServiceProxy class implements the IOrganizationService and provides an authenticated WCF channel to the organization, in this case, can i use the higher class OrganizationService and use CrmConnection(string connectionStringName); ?

i have changed ClientCredentials with ClientCredential and implement "Microsoft.IdentityModel.Clients.ActiveDirectory" and use AzureAD authentification but i had same problem beacuse the constructor take ClientCredientials in arguement
public OrganizationServiceProxy(Uri uri, Uri homeRealmUri, ClientCredentials clientCredentials, ClientCredentials deviceCredentials);

I wait any suggestions to resolve this problem

Thank-you for your prompt response

Cordially

@HASSEN-MEDDEB-ATOS
Copy link

HASSEN-MEDDEB-ATOS commented Feb 7, 2020

i did this

CrmServiceClient client = new CrmServiceClient("Url=*********************; Username=*****************; Password=***************; authtype=Office365");

                sp = client.OrganizationServiceProxy;
                sp.ServiceConfiguration.CurrentServiceEndpoint.EndpointBehaviors.Add(new ProxyTypesBehavior());

I had another error
Could not load file or assembly 'System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Cordially

@HASSEN-MEDDEB-ATOS
Copy link

HASSEN-MEDDEB-ATOS commented Feb 10, 2020

Hello again :D,

i have searched antoher solution for my issue, i have find that we can integrate SOAP web Services in .NET Core. i used WCF Web Service Reference Provider. I downloaded WSDL from my CRMDynamics365 and generated code from WSDL File. But the herror, i can't set up endpoint and user credentials beaucse this code is not found in my code :/

Normally we could have this code :/

private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(TimeSpan timeout)
{
  var httpsBinding = new BasicHttpsBinding();
  httpsBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
  httpsBinding.Security.Mode = BasicHttpsSecurityMode.Transport;

  var integerMaxValue = int.MaxValue;
  httpsBinding.MaxBufferSize = integerMaxValue;
  httpsBinding.MaxReceivedMessageSize = integerMaxValue;
  httpsBinding.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
  httpsBinding.AllowCookies = true;

  httpsBinding.ReceiveTimeout = timeout;
  httpsBinding.SendTimeout = timeout;
  httpsBinding.OpenTimeout = timeout;
  httpsBinding.CloseTimeout = timeout;

  return httpsBinding;
}
 
private static System.ServiceModel.EndpointAddress GetEndpointAddress(string endpointUrl)
{
  if (!endpointUrl.StartsWith("https://"))
  {
      throw new UriFormatException("The endpoint URL must start with https://.");
  }
  return new System.ServiceModel.EndpointAddress(endpointUrl);
}
public MyServicePortTypeClient(string endpointUrl, TimeSpan timeout, string username, string password) :
 base(MyServicePortTypeClient.GetBindingForEndpoint(timeout), MyServicePortTypeClient.GetEndpointAddress(endpointUrl))
{
   this.ChannelFactory.Credentials.UserName.UserName = username;
   this.ChannelFactory.Credentials.UserName.Password = password;
   ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
}
 
public MyServicePortTypeClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
 base(binding, remoteAddress)
{
}

I had this when i generate reference
"Endpoints is not compatible with .Net Core applications ."

"Warning: Unable to import wsdl: binding
Details: An exception was thrown in a call to a policy import extension.
Extension: System.ServiceModel.Channels.SecurityBindingElementImporter"

Cordially

@StephenBonikowsky
Copy link
Member Author

@HASSEN-MEDDEB-ATOS

I downloaded WSDL from my CRMDynamics365 and generated code from WSDL File.

Would it be possible for you to provide us with your WSDL? That would help us fully understand what binding configuration you are using.

@HASSEN-MEDDEB-ATOS
Copy link

HASSEN-MEDDEB-ATOS commented Feb 11, 2020

Hello @StephenBonikowsky

Thank you so much for your resposne
Can you give me your Email. i will send you the file because i can't upload .cs file type :/

Cordially

@StephenBonikowsky
Copy link
Member Author

StephenBonikowsky commented Feb 11, 2020

@HASSEN-MEDDEB-ATOS Please send it to *******@microsoft.com

EDIT: [mconnew] I removed the email address now I've received the email to hide from spam scrapers.

@HASSEN-MEDDEB-ATOS
Copy link

HASSEN-MEDDEB-ATOS commented Feb 13, 2020

Hello
i have sent the file to Matt without response, meanwhile, i have find another solution but i have same issue when the generated file, in this solution, i have managed to get it working using Unchase OData Connectedservice, but i can't find orgContext :/

Cordially

@mconnew
Copy link
Member

mconnew commented Feb 13, 2020

I've looked at your WSDL and it looks like you will need WSFederationHttpBinding. We should have support for that soon. I need to spend a bit more time validating that the work we're doing will be sufficient for your use case. I'll try to get to that in the next few days.

@HASSEN-MEDDEB-ATOS
Copy link

HASSEN-MEDDEB-ATOS commented Feb 13, 2020 via email

@mconnew
Copy link
Member

mconnew commented Feb 14, 2020

It will be cross platform on .NET Core so will work on all Linux distro's that .NET Core is supported on. We're waiting on a deliverable from another team before we can move forward and there's been a few delays so I can't comment on an expected release date at this point. I can tell you it won't be by Feb 19th though as there's still a few weeks worth of work to get done after the other team provides their piece. I also need to validate that the specific WS-* protocol versions you are using will be supported.

@JoeriBlootacker
Copy link

I'm in the same situation as Hassen-Meddeb-Atos, i'm trying to connect to Dynamics CRM through .Core, and am facing the same issues. so i'm curious to see the WSFederationHttpBinding implementation.

Will keep a close eye on this thread :)

Regards

@HASSEN-MEDDEB-ATOS
Copy link

Hello,
@mconnew is there any news please

Cordially

@HASSEN-MEDDEB-ATOS
Copy link

HASSEN-MEDDEB-ATOS commented Mar 1, 2020

Hello Everyone,

I came across an article talk about .NET Core CDS SDK Alpha Availability, it's incredible, i have finally succeed to connect to Dynamics CRM using Microsoft.Powerplatform.Cds.Client;

 var s1 = @"AuthType=Office365;
                       Url=*******;
                       UserName=*****@*****.onmicrosoft.com;
                       Password=******";
                var conn = new CdsServiceClient(s1);

but i can't find OrganizationServiceProxy because it has deperceated ;'(

Any suggestion please, need to make it work so urgent

Thank you for the work you have done
Cordailly

@StephenBonikowsky
Copy link
Member Author

@HASSEN-MEDDEB-ATOS The work on WSFederationHttpBinding is progressing. I understand you have a pressing schedule, other businesses are also blocked on having WSFederationHttpBinding available and it is being actively worked on.

I understand you are looking into other solutions, unfortunately we don't have expertise on Dynamics 365 APIs.

Have you tried reaching out on the Dynamic 365 site? I found a quite a few posts regarding .NET Core.

@HASSEN-MEDDEB-ATOS
Copy link

HASSEN-MEDDEB-ATOS commented Mar 4, 2020

@StephenBonikowsky @mconnew

Hello,

microsoft announced the availability of CdsServiceClient on .NET Core, I tried a lot of authentication type and the result is the same,

  string connectionstring = ConfigurationManager.ConnectionStrings["connectionVSMPSecretkey"].ConnectionString;
                        sp = new CdsServiceClient(connectionstring);

i used client secret authentification

<add name="MyCDSServer" 
  connectionString="
  AuthType=ClientSecret;
  url=https://contosotest.crm.dynamics.com;
  ClientId={AppId};
  ClientSecret={ClientSecret}
  /> 

but i get error System.ServiceModel.Security.MessageSecurityException: The HTTP request was forbidden with client authentication scheme 'Anonymous'.

I have invesitgated in this issue and maybe it's related with wsHttpBinding :'(

the only thing that bothers me, when i tested my authentification with postman using clientcredntial it work fine
Tocken

I apperciate any suggesstion from you

Cordially

@HASSEN-MEDDEB-ATOS
Copy link

Hello again,
How can i implement CustomBinding like this in my code
var binding = new CustomBinding
{
Elements = { new HttpTransportBindingElement //or HttpTransportBindingElement for https:
{
MaxBufferSize = int.MaxValue,
MaxReceivedMessageSize = int.MaxValue,
AuthenticationScheme = AuthenticationSchemes.Anonymous
}}
};
Cordially

@StephenBonikowsky
Copy link
Member Author

Could you please search the repo under https://github.com/dotnet/wcf/tree/master/src/System.Private.ServiceModel/tests
For "CustomBinding" or anything else you are interested in and see what is there first.

@HASSEN-MEDDEB-ATOS
Copy link

Hello,

The test to connect to dynamics crm was carried out successfully using CDS SDK in .NET Core using connection string with client secret authentification, the solution is not very reliable because CDS SDK hasn't any stable version

Cordially

@abisheksharma
Copy link

I am not sure if this helps but there is a nuget package now Microsoft.PowerPlatform.Dataverse.Client that can help to connect to Dynamics 365.

@montella1507
Copy link

Well typical microsoft... They just everyone left behind..

@mconnew
Copy link
Member

mconnew commented Aug 27, 2021

@montella1507, what's been left behind? We've now shipped WS-Federation support for .NET Core so you should be unblocked now. Is there more needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer assistance Help customers with questions regarding usage of WCF features.
Projects
None yet
Development

No branches or pull requests

6 participants