views:

5

answers:

1

I am currently developing a WCF service .net 4.0 which has got 2 properties. For some reason those property is not visible on the client.

Following is the code for the service.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Data;
using System.IO;
using System.Configuration;

using Longview.ScatIt.Data.Model;
using Longview.ScatIt.Service.Contract;

namespace Longview.ScatIt.Service
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "SqlJob" in code, svc and config file together.
    [ServiceContract]
    public class SqlJob : ISqlJob
    {

        #region IJob Members

        [DataMemberAttribute(Name="FileName")]
        internal string _fileName;

        [DataMemberAttribute(Name = "Location")]
        internal string _location;

        #endregion
    }
}

I read somewhere on internet that in partial trust property need to be defined as "internal" and add [assembly: InternalsVisibleTo("System.Runtime.Serialization")] attribute in AssemblyInfo.cs in the service contract.

Am I doing something wrong because of which those to properties are not visible on the server?

Any suggestion is appriciated

Thanks

A: 

You're mixing up two different things:

  • You can have services that are decorated with the ServiceContract attribute. A service has a set of methods that you wish to expose via OperationContracts.
  • A service method can return or accept objects that you decorate with the DataContract attribute. Data contracts have members that should use the DataMember attribute.

What you have now is a service contract with data members. This doesn't make sense.

Here are some more links for services and data contracts.

Ronald Wildenberg