Service reference not generating client types
Service reference not generating client types
I am trying to consume a WCF service in a class library by adding a service reference to it. In one of the class libraries it gets consumed properly and I can access the client types in order to generate a proxy off of them. However in my second class library (or even in a console test app), when i add the same service reference, it only exposes the types that are involved in the contract operations and not the client type for me to generate a proxy against.
e.g. Endpoint has 2 services exposed - ISvc1 and ISvc2. When I add a service reference to this endpoint in the first class library I get ISvc1Client andf ISvc2Client to generate proxies off of in order to use the operations exposed via those 2 contracts. In addition to these clients the service reference also exposes the types involved in the operations like (type 1, type 2 etc.) this is what I need. However when i try to add a service reference to the same endpoing in another console application or class library only Type 1, Type 2 etc. are exposed and not ISvc1Client and ISvc2Client because of which I cannot generate a proxy to access the operations I need. I am unable to determine why the service reference gets properly generated in one class library but not in the other or the test console app.
Answer by Cranialsurge for Service reference not generating client types
Apparently you have to add a reference to System.Web in your project before adding the Service Reference. That did it.
Answer by Kevin for Service reference not generating client types
The real answer is, if you are serializing a type using the KnownTypeAttribute on your service contract, you MUST include a reference to your type's library in the project you are adding the service reference to.
For example, if your wcf service serializes the type System.Drawing.Image, then the consumer project MUST have a reference to System.Drawing. Hope this helps some folks out there.
Answer by rsuharta for Service reference not generating client types
This normally happens for adding a service reference that you had added before. In the client config, it still has the relevant servicemodel. Make sure you delete the servicemodel from the client config and then try to re-add the service reference again!
Answer by Simon_Weaver for Service reference not generating client types
You may have selected Reuse types in specified reference assemblies
but not chosen the very important mscorlib
library.
First click 'Show All Files' at the top of your Solution Explorer so you can expand out the service reference.
- Find the
Reference.cs
file and open it. - Search for
ClientBase
in the source code to make sure you really haven't generated a client with a name you weren't expecting. If you find it then that's the name of your service client.
If nothing matches then right click the service reference and choose Configure Service Reference
.
The important one is mscorlib
which is required to properly generate the client. I like to select System.Xml.Linq
also to get nice Linq classes like XElement
and not XmlElement
.
Answer by TrueEddie for Service reference not generating client types
I encountered the same issue. Turns out my project was referencing a DLL directly instead of a project reference. So even though my project had a reference for the assembly, it was to an old version. Once I updated the DLL and updated the service reference everything was working again.
Answer by arif.khan.b for Service reference not generating client types
I'd faced similar issue this is due to type mismatch. Because of which I was not able to generate the client in the test project. We maintain different versions of contracts, while creating new version I'd introduced type mismatch error. Following was the code scenario in my case.
Version 1 Contract
[DataContract(Namespace="http://www.exmample.com/v1")] public enum Fruits { [EnumMember] Apple, [EnumMember] Orange }
Version 2 Contract
[DataContract(Namespace="http://www.exmample.com/v1")] public enum Fruits { [EnumMember] Apple, [EnumMember] Orange, [EnumMember] Mango }
I've resolved this issue using svcutil command line utility. Command
svcutil MyContract.dll
I got the below error message
DataContract for type 'V2.Fruits' cannot be added to DataContractSet since type 'V1.Fruits with the same data contract name 'Fruits' in namespace 'http://www.exmample.com/v1' is already present and the contracts are not equivalent.
I changed the namespace from version 1 to version 2 and I was able to generate service reference in test project.
[DataContract(Namespace="http://www.exmample.com/v2")] public enum Fruits { [EnumMember] Apple, [EnumMember] Orange, [EnumMember] Mango }
Make use of svcutil this will help to resolve this issue.
Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72
0 comments:
Post a Comment