Click here to Skip to main content
15,940,550 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am learning WCF web services and I come across this article Dynamic (runtime) Generation of a WCF Service contract, about creating service contract dynamically. I downloaded the given code and tried running it but it didn't succeed. It throws the following error:

{"The requested service, 'http://localhost/WcfService1/Service5.svc' could not be activated. See the server's diagnostic trace logs for more information."}

I think it is unable to register the wcf service dynamically. To check it I changed the console application code little bit and referenced the WcfService1 assembly directly instead of ServiceRefence. The code looks as below:

C#
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Channels;
using WcfService1; // Referenced the assembly directly instead of ServiceRefernce (Add References option)


namespace ConsoleClient
{
    class Program
    {

        static void Main(string[] args)
        {
            
                GenerateGetRequest();
               
               
        }
        
        private static void GenerateGetRequest()
        {
            //Generate get request
            string url = "http://localhost/WcfServices/Service5.svc";
            HttpWebRequest GETRequest = (HttpWebRequest)WebRequest.Create(url);
            GETRequest.Method = "GET";

            Console.WriteLine("Sending GET Request");
            HttpWebResponse GETResponse = (HttpWebResponse)GETRequest.GetResponse();
            Stream GETResponseStream = GETResponse.GetResponseStream();
            StreamReader sr = new StreamReader(GETResponseStream);

            Console.WriteLine("Response from Server");
            Console.WriteLine(sr.ReadToEnd());
            Console.ReadLine();
        }
       
    }
}


In the above code i am using HttpWebRequest and HttpWebResponse methods to access the Web Service which is registered dynamically.

As I am a beginner in WCF and DI (Dynamic Injection), I am stuck.
I suppose am doing something wrong. Please suggest me the way to run this successfully and steps to do it.

Thanks in advance.
Posted

First my suggestion is to contact the original author about this.

At the mean time, you can try some solutions suggested by Google. I am giving some links below. Try the solutions explained there.

1. The requested service, ‘http://Service.svc’ could not be activated. See the server’s diagnostic trace logs for more information.[^]
2. WCF Service - could not be activated[^]
 
Share this answer
 
Hi,
This problem is solved. Actually the issue was with the downloaded zip file. I downloaded it again and unblocked the zip file before unzipping it.

Thanks.
 
Share this answer
 
v2

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