Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.86/5 (3 votes)
See more:
Hi. I am creating some contracts and implementing them in a WCF service. I have the following code:

C#
public interface IContent
    {
        [OperationContract]
        bool AddContent(string description, string location, int userID);
    }
    [DataContract]
    public class ContentData
    {
        [DataMember]
        public String Description;

        [DataMember]
        public String Location;
    }


It is implemented as thus:

C#
public bool AddContent(string description, string location, int userID)
{
    ...
}


When I run the service in the test client, and for location pass a path, such as:

E:\My Documents\Content\testcontent.txt

A DbEntityValidationException error is thrown with the Error Message: The Location field is required.

On debugging, the location parameter in the implementation comes in null.

When I try and pass a plain string for location without the path's '\', e.g. if I enter a value such as "This should work!", it works :-(..

How can is solve the backslash problem? I am confused on what could be wrong.
Posted
Updated 2-Feb-14 18:51pm
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900