tags:

views:

52

answers:

2

Hello, I'm using WCF. At client side, I have this class without [DataContract]:

public class UserEntity
    {
        public string login;
        public string password;
    }

when I put [DataContract] and refresh the reference of this class at WCF side, then I can't initiate the web service. It says an error "cannot create metadata"... What's wrong please?

A: 

Are you sure that you actually know, why you can't refresh the reference? I mean you add [DataMember] - and it fails, you remove it - it works? Or it works several days ago and now you add [DataMember] (and many other stuff) and it not works now?

But anyway, the easiest way to solve "refresh reference" issues - to refresh reference manually with SvcUtil.exe. In this case error message would be much more descriptive the simple "oops! error!".

Sergey Teplyakov
yes, i'm really sure that only when I add [DataContract], it gives the error. But I already solved by putting the Entity at WCF side.But at WCF side I cant create a Library for Entities and a Library for DAO. Is this common?
Alan
You may "crash" it again and try to refresh reference with SvcUtils. It shows you, what wrong. In my application I use shared assembly for server and client (I know, that isn't truly SOA-way but it easier for me)... But maybe I don't understand your position about "Library for Entities":)
Sergey Teplyakov
A: 

What is client and server side in your case? What is refreshing reference on the WCF side? Your description is very uncommon. Here is description how to create service with complex data type and WCF Class library:

  • Create WCF class library
  • Add data contract to the class library
  • Add service to class library
  • Implement service contract and service in the class library
  • Add host project
  • Reference WCF class library from host project
  • Host service from class library in host project
  • Add Metadata endpoint to your hosted service
  • Create client project
  • Run the host project outside the visual studio
  • Use Add service reference to create proxy on WCF service hosted in your host project
  • Implment code to call your service through created proxy

As you see there is no modification of data contract on the client side and no refreshing WCF service.

Ladislav Mrnka