WCF Async Web Services issues - c#

I'm having several issues with my WCF client in that the client Reference.cs is empty and the only error I get on the build is the useless generic message:
Severity Code Description Project File Line Suppression State
Warning Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://tempuri.org/']/wsdl:portType[#name='IBrokerWcf'] MyWeb.Setup C:\Users\me\Projects\MyWeb 3.x\MyWeb v3.x\MyWeb.Setup\Service References\BrokerWcfSvc\Reference.svcmap 1
When I load the Service in the WCF Test Client, all of the advertised async methods error out (see image) with "This Operation is not supported in the WCF Test Client because it uses type System.Threading.Tasks.Task'1"
All of this previously worked fine. Not sure what changed to send it all sideways.

System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: The located assembly's manifest definition does not match the
assembly reference.
As the error says, the manifest definition of the locating assembly does not match the assembly reference.
You need to check the components. Did you click "Reuse types in referenced assemblies" when adding a service reference.
This Operation is not supported in the WCF Test Client because it uses
type System.Threading.Tasks.Task'1"
The "error" you are seeing is just a limitation of the test tool that comes with visual studio, both functions call the same server side function so there is no compelling force to make Microsoft add support. There is no actual error. If you really want to test the async version you will need to write your own test client that calls the function.
Error : not supported in WCF Test client because it uses type System.Threading.Tasks

Related

Strong name signature not valid for this assembly

I've just started to get the following error in my clickonce application. I have just installed visual studio 2019 on my machine prior to this "Application validation did not succeed. Unable to continue.
when i click into details I get
Activation of C:\Temp\ClickOnce\myApp\myApp.application resulted in exception.
Following failure messages were detected:
Strong name signature not valid for this assembly DevExpress.Utils.v21.1.dll.
I also get two warnings but I do not believe they are the cause of the problem
The manifest for this application does not have a signature. Signature validation will be ignored.
The manifest for this application does not have a signature. Signature validation will be ignored.

Error trying to add a web reference to dotnet core project. User canceled out of save dialog (Exception from HRESULT: 0x8004000C (OLE_E_PROMPTSAVECA

I have a dotnet core project that I need to a web reference to. I select the Microsoft WCF Web Service Reference provider and select the URL and click "Go" The correct service shows up under the "services" window. I change the namespace to something like mynewservice and press "finish."
The new window show adding connected service to project.
Importing web service metadata ...
Number of service endpoints found: 2
Scaffolding service reference code ...
Warning:Warning: Reference cannot be loaded: 'System.Data.Entity', Could not load file or assembly 'System.Data.Entity, Culture=neutral, PublicKeyToken=null'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
Updating project ...
Error:User canceled out of save dialog (Exception from HRESULT: 0x8004000C (OLE_E_PROMPTSAVECANCELLED))
Done.
Error:Adding Microsoft WCF Web Service Reference Provider to the project failed: User canceled out of save dialog (Exception from HRESULT: 0x8004000C (OLE_E_PROMPTSAVECANCELLED))
What do I need to do to get the reference installed? I've looked at previous examples and they usually indicate the proj file is locked but I can edit the proj file so it isn't locked. Any ideas?
I never found an answer, however the method suddenly starting working and I no longer got the error. Not sure what changed but now it installs correctly.

The mysterious "Couldn't not load file or assembly 'System.ServiceModel, Version=4.0.0.0..." error

Scenario: I have a WCF endpoint (endpoint Manufacturing) that connects another WCF endpoint (endpoint DataAPIClient) as ConnectedService. The constructor of an entity in A instantiate the "client" (see below). On top of all these, I have a xUnit test project testing A.
// Manufacturing constructor
public Manufacturing() {
client = new DataAPIClient();
}
// Instantiating in the xUnit project
Manufacturing endpoint = new Manufacturing();
Problem: Something changed (and I couldn't figure out what) that when the test project tries to instantiate Manufacturing. I got this error:
Message: System.IO.FileNotFoundException : Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
I have verified the System.ServiceModel.dll in both endpoints. DataAPIClient has 4.0.30319 and manufacturing has 4.0.0.0.
P.S. I did change the name of the Manufacturing project...not sure if that caused that, but I thought it might be worth of mentioning.
Any help is greatly appreciated...I've been googling and found nothing.
per howcheng's suggestion, I noticed that since I was using xUnit Test Project (.NET Core), I couldn't (or maybe I just didn't know how) add any reference to System.ServiceModel.dll. So I created a Unit Test Project (.NET Framework) and added the xUnit Nugets and System.ServiceModel.dll assembly. The error went away.

Azure Functions : HttpRequestMessage does not contain a definition for 'CreateResponse'

I built a c# Azure functions app triggerred by an Http Request. The purpose of this app is to use digital twin to change the desired status of my device. In order to do that, I have imported the following dependencies (within the project.son file):
"Microsoft.Azure.Devices": "1.17.2",
"Microsoft.Azure.Devices.Client": "1.19.0",
"Microsoft.Azure.Devices.Shared": "1.15.2",
"Newtonsoft.Json": "12.0.1"
Here is my error, when I want to return a HttpResponseMessage
req.CreateResponse<string>(HttpStatusCode.BadRequest, "Please pass a status on the query string or in the request body");
I get the following error :
[run.csx] 'HttpRequestMessage' does not contain a definition for 'CreateResponse' and the best extension method overload 'HttpRequestMessageExtensions.CreateResponse<string>(HttpRequestMessage, HttpStatusCode, string)' requires a receiver of type 'HttpRequestMessage'
I suspect dependencies to cause this error but I haven't found any solution on internet.
Do you have an idea how to solve this ?
Thanks
Solution:
Go to kudu(https://<functionapp>.scm.azurewebsites.net/DebugConsole) and navigate to D:\home\data\Functions\packages\nuget, delete system.net.http package then restart the function app.
Explanation:
HttpRequestMessage locates at assembly System.Net.Http.dll. I found that Function host references the assembly from GAC(Global Assembly Cache). On Azure, file path is D:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll. The reference cannot be redirected to the one we install using nuget(packages you installed reference System.Net.Http.dll internally), or we'll get error.

WCF Protocol Exception

I am experiencing real problems with WCF. For no apparent reason I have started getting the following errors when debugging any WCF service in my solution:
ProtocolException Occurred Content
Type application/soap+xml;
charset=utf-8 was sent to a service
expecting text/xml; charset=utf-8.
The client and service bindings may be
mismatched.
Clicking continue on the exception window details leads on to a different exception:
Could not load file or assembly
'System.Xml.XmlSerializers,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' or
one of its dependencies. The system
cannot find the file specified.
The Disassembly window in Visual Studio also appears when these exceptions occur.
After clicking continue until the exceptions stop the WCF Test Client starts but invoking any of my service methods gives me this exception:
PlatformNotSupportedException The
specified cryptographic algorithm is
not supported on this platform.
I tried to add my existing service to a new blank solution and the errors ceased. However, after running my service a couple of times, the errors have started again.
I actually have two WCF services in my solution (one a WCF Workflow Service and one a WCF service that exposes data access methods (Entity Framework), a web application and a few other supporting class libraries. Attempting to run the web application or any service in isolation now gives me the same Protocol Exception.
Any help will be greatly appreciated. I am using Visual Studio 2010, targeting 4.0 of the .Net Framework.
Thanks
I also experienced the
Could not load file or assembly 'System.Xml.XmlSerializers, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
error message. My assembly references were correct, so very odd indeed. To get rid of the error, I found the following to work (hoping for an explanation here some time in the future). :)
Visual Studio top menu : Debug > Exceptions > Reset all
Ref this post by Peter G.
Hope this helps,

Categories

Resources