Avatar of panJames
panJames
 asked on

Web.config made automatically according to WCF service

Hello experts!

I am trying to get my head around example I found on internet.

I am trying to re- create the example of simple service I found on internet.

This is what I do:

1. VS2005 Pro -> new project -> class library

2. I have three files my service consists from:


A.

*** DataContract.cs***


using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace SampleService
{
    [DataContract]
    public class Request
    {
        string name;

        [DataMember]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
    }

    [DataContract]
    public class Response
    {
        string message;

        [DataMember]
        public string Message
        {
            get { return message; }
            set { message = value; }
        }
    }

}


B.

***Service.cs***

using System;
using System.Collections.Generic;
using System.ServiceModel;

namespace SampleService
{
    [ServiceBehavior]
    public class Service: ISampleService
    {
        [OperationBehavior]
        public Response GetMessage
            (
            Request request
            )
        {

            Response response = new Response();

            if ( null == request )
            {
                response.Message = "Error!";
            }
            else
            {
                //set the message
                response.Message = "Hello, " + request.Name;
            }

            return response;
        }

        [OperationBehavior]
        public string SayHello()
        {
            return "Hello, World!";
        }
    }
}

C.

***ServiceContract.cs***

using System;
using System.ServiceModel;

namespace SampleService
{
    [ServiceContract]
    public interface ISampleService
    {
        [OperationContract]
        Response GetMessage
            (
            Request request
            );

        [OperationContract]
        string SayHello();
    }
}

I understand that I need service.svc file, so I have it:

***Service.svc***

<% @ServiceHost
            Language=C#
            Service="SampleService.Service"
%>



Questions:


1. How can I configure VS to create Web.Config file automatically when I build my service and put it into selected folder?

Thank you

panJames




.NET ProgrammingC#

Avatar of undefined
Last Comment
panJames

8/22/2022 - Mon
panJames

ASKER
And also how to configure VS to make it copy built service.dll into two different folders automatically?

Thank you

panJames
ASKER CERTIFIED SOLUTION
SunnyDark

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
panJames

ASKER
SunnyDark:

tried:

copy $(TargetPath) "C:\Some folder to copy to\" /y
copy $(TargetPath) "C:\Some folder to copy to\"

It says: system didn't find the file specified.

Which is weird because paths I can see in the output message are correct.

******************************
Tried such a thing:

copy "I typed the same path I could read from output message" "C:\Some folder to copy to\"

it works fine!

Any idea what is going on?

Thank you

panJames

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy