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
Avatar of panJames
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
Avatar of SunnyDark
SunnyDark
Flag of Israel image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of panJames
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

.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo