Add service reference fail - c#

I have WCF Service, that has callback.
When I have 25 methods in callback all fine, but if I add 26-th method, Visual Studio(2013) can't update or add service reference. WTF?
Error message:
The URI prefix is not recognized.
Metadata contains a reference that cannot be resolved: 'net.tcp://127.0.0.1:9001/XXX.WCF/WCFService/mex'.
Metadata contains a reference that cannot be resolved: 'net.tcp://127.0.0.1:9001/XXX.WCF/WCFService/mex'.
If the service is defined in the current solution, try building the solution and adding the service reference again.

Related

WCF Web Service / Visual Studio Community 2022 / Compiler Error CS0120

I want to access a web page in a Windows Forms app via SOAP.
Unfortunately, the compiler spits out many errors after I added the WCF Web Service to the project. What am I doing wrong here? The possible options don't tell me anything. The examples I found on the Internet could not help me with the errors.
Visual Studio Community 2022
WCF Web Service
URI: https://www.onlinembe.de/wsdl/OnlineMbeSOAP.wsdl
[ ] Always generate message contracts
[X] Reuse types in referece assemblies
[X] Reuse types in all referenced assemblies
Access level for generated classes:
[X] Public
Compiler Error CS0120
An object reference is required for the non-static field, method or property "ShipmentRequestType.System".
In 'Reference.cs' add 'using System.Xml.Schema;'
and replace
'Form=System.Xml.Schema.XmlSchemaForm.Unqualified'
with
Form='XmlSchemaForm.Unqualified'.

OpenSilver with Service References

Im trying to migrate a Silverlight application to OpenSilver.
The application uses WCF service references that are included in the project.
I followed the OpenSilver example on migrating from Silverlight to OpenSilver
https://doc.opensilver.net/documentation/migrate-from-silverlight/example.html
After wrapping the application with the OpenSilver files I get an error that my services namespace could not be found, then when trying to add that missing service reference to the project I get "The target framework 'netcoreapp2.0' is out of support"
Is there a step I am missing in setting this up?
If you get the error because you copy-pasted the server references as well
If you double click that error it should bring you to the Reference.svcmap file of your WCF service reference. Find the Reference.cs file in Solution Explorer next to Reference.svcmap.
Open it and you will see the same error multiple times in the code:
"The type name 'IHttpCookieContainerManager' could not be found in the namespace 'System.ServiceModel.Channels'. This type has been forwarded to assembly 'System.ServiceModel.Http, Version=4.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly."
Solution: add the following nuget package: System.ServiceModel.Http
If you try to add a new service reference then follow this workaround: https://github.com/dotnet/wcf/issues/4766#issuecomment-1007859628
I hope that helps.

Error Adding Service Reference to WinForm project

I want to consume a live service in my project but when I tried to add its reference, following error came:
The document at the url https://exdev.www.property24.com/Services/P24ListingService19.asmx was not recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'XML Schema' is 'The root element of a W3C XML Schema should be and its namespace should be 'http://www.w3.org/2001/XMLSchema'.'.
- Report from 'DISCO Document' is 'Discovery document at the URL https://exdev.www.property24.com/Services/P24ListingService19.asmx could not be found.'.
- The document format is not recognized (the content type is 'application/xhtml+xml; charset=utf-8').
- Report from 'WSDL Document' is 'There is an error in XML document (3, 2).'.
- was not expected.
Metadata contains a reference that cannot be resolved: 'https://exdev.www.property24.com/Services/P24ListingService19.asmx'.
Metadata contains a reference that cannot be resolved: 'https://exdev.www.property24.com/Services/P24ListingService19.asmx'.
If the service is defined in the current solution, try building the solution and adding the service reference again.
The Service URL can be browsed that is: https://exdev.www.property24.com/Services/P24ListingService19.asmx
I tried to add that web service reference under "Service References" but that was giving the above error.
The problem was that the Web Service was old so i managed to get its working reference by going to the "Advance" of Service Reference and adding it as "Web Reference".
As Web Reference can cope with old services.
It worked for me, hope it also will work for you!

Metadata contains a reference that cannot be resolved (Wrong wsdl url)

When adding a web reference or a service reference, visual studio 2010 shows the following error message. Actual wsdl url is http://x.x.x.x:9999/PersonCRUD.asmx?wsdl. I don't know why visual studio tries to download from http://x.x.x.x/PersonCRUD.asmx?wsdl
Metadata contains a reference that cannot be resolved: 'http://x.x.x.x/PersonCRUD.asmx?wsdl'.
There was an error downloading 'http://x.x.x.x/PersonCRUD.asmx?wsdl'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://x.x.x.x:9999/PersonCRUD.asmx'.
Metadata contains a reference that cannot be resolved: 'http://x.x.x.x:9999/PersonCRUD.asmx'.
If the service is defined in the current solution, try building the solution and adding the service reference again.
At the end of the wsdl there is the part that contains the wrong urls. I guess it's the source of the problem. (port :9999 is missing)
<wsdl:port name="PersonCRUDSoap" binding="tns:PersonCRUDSoap">
<soap:address location="http://78.186.32.181/PersonCRUD.asmx"/>
</wsdl:port>
<wsdl:port name="PersonCRUDSoap12" binding="tns:PersonCRUDSoap12">
<soap12:address location="http://78.186.32.181/PersonCRUD.asmx"/>
</wsdl:port>
BTW I tried this in a fresh new web site project.
Is there anyone who have a clue why this error occurs?
Thanks.

The type 'StringPro.IMyString' is defined in an assembly that is not referenced

I receive this error when trying to run the client.
The type 'StringPro.IMyString' is defined in an assembly that is not referenced.
This error comes from, StringProClient from file Program.cs and underlines in blue the following first line of code:
StringProProxy.StringProProxy proxy = new StringProProxy.StringProProxy();
The solution has 4 projects inside:
StringPro - Class Library that contains the service's interface(IMyString.cs) and the implementation class(MyString.cs)
StringProHost - Console Application that has Program.cs inside which defines Uri, ServiceHost, Endpoint, ServiceMetadataBehaviour, HttpGetEnabled, host.Description.Behaviours, calls host.Open() and displays in console information about when the service was started
StringProProxy - I believe it's a Class Library project since it has only StringProProxy.cs which defines the service's proxy
StringProClient - Console Application which instantiates the service's proxy inside, call the service's functions and displays results.
EDIT: The service host launches fine. It's the client that won't build and run because of the mentioned error.
If a project is using a type that was declared in other assembly, this assembly must be referenced - this is basically what your error is telling you.
In your case, I'm guessing that StringProClient is referecing StringProProxy, but it is also using types declared in StringPro project (to be exact: IMyString interface/class), without referencing it. You should make sure, that StringProClient references both, StringProProxy and StringPro.
Such problem mostly arises with the issues like namespace only. Kindly check your references as well as namespaces again.

Categories