Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
BRH 58
#ASP.NET 55
ASP.NET 50
#DOTNET 49
.NET 40
WCF 21
DOTNET 12
c# 8
windows azure 7
SILVERLIGHT 7

Archive · View All
April 2011 9
March 2011 9
February 2011 8
December 2010 7
November 2010 5
September 2010 5
August 2010 5
May 2011 4
October 2010 4
January 2011 2

WebException or Remote server name could not be resolved in WCF Data Service

Sep 7 2010 6:01AM by Dhananjay Kumar   

Objective

This article will give a brief explanation on how to handle remote server name could not resolved exception in WCF Data Service. If you are new to this topic, please read Introduction to WCF Data service and ODATA before going through below article. Let us say, there is a WCF Data Service up and running on a particular server. We access that using below code at the client side

Program.cs

using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Data.Services.Client;
using ConsoleApplication1.ServiceReference1; 
namespace ConsoleApplication1
{
    classProgram
    {
        staticvoid Main(string[] args)
        {
            DataServiceContext context = newDataServiceContext(newUri("http://localhost:61091/WcfDataService1.svc/"));
            DataServiceQuery query = context.CreateQuery("Employees");
            foreach (Employee e in query)
            {
                Console.WriteLine(e.FirstName);
            }
            Console.Read();
        }
    }
}

And output is as below,

Output1

Every this is fine till this point. Now let us go ahead and modify the WCF Data Service URL to a false URL

DataServiceContext context = newDataServiceContext(
                             newUri("http://abc:61091/WcfDataService1.svc/"));

And URL, I am giving is false one. Server abc does not exist. Now after modification code will look like

using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Data.Services.Client;
using ConsoleApplication1.ServiceReference1; 
namespace ConsoleApplication1
{
    classProgram
    {
        staticvoid Main(string[] args)
        {
            DataServiceContext context = newDataServiceContext(
                                         newUri("http://abc:61091/WcfDataService1.svc/"));

            DataServiceQuery query = context.CreateQuery("Employees");
            foreach (Employee e in query)
            {
                Console.WriteLine(e.FirstName);
            }
            Console.Read();
        }
    }
}

And when you try to run, you will get the run time exception as below,

WebException In Unhandled

Now to handle this exception put the foreach statement in try catch , so no modified code will look like

using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Data.Services.Client;
using ConsoleApplication1.ServiceReference1; 
namespace ConsoleApplication1
{
    classProgram
    {
        staticvoid Main(string[] args)
        {

            DataServiceContext context = newDataServiceContext(
                                         newUri("http://abc:61091/WcfDataService1.svc/"));

            DataServiceQuery query = context.CreateQuery("Employees");
            try
            {
                foreach (Employee e in query)
                {
                    Console.WriteLine(e.FirstName);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.Read();
        }
    }
}

And now running output will be as below,

Output2

Tags: #DOTNET, #WCF, DOTNET, WCF, #ASP.NET, BRH, ODATA,


Dhananjay Kumar
49 · 4% · 1198
0
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]