473,410 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

Error when adding Service References containing Exception classes.

Hi,
I'm trying to return exceptions from a WCF Service using FaultExceptions. I
got the service compiled and running. But I get an error while adding a
service reference to it. The error reads:
"
Attempting to download metadata from
'http://localhost:4619/WCFService1/Service.svc' using WS-Metadata Exchange or
DISCO.
Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension:
System.ServiceModel.Description.DataContractSerial izerMessageContractImporter
Error: ISerializable type with data contract name 'ServiceException' in
namespace 'http://schemas.datacontract.org/2004/07/' cannot be imported. The
data contract namespace cannot be customized for ISerializable types and the
generated namespace 'BScreened.WS.Test.localhost' does not match the required
CLR namespace ''. Check if the required namespace has been mapped to a
different data contract namespace and consider mapping it explicitly using
the namespaces collection.
XPath to Error Source:
//wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='IService']
"

Something seems to be wrong with the Service Exception class but I don't
understand what. Ideas anyone?
My service looks like this:

----------
Service.cs
----------
using System;
using System.ServiceModel;
using System.Runtime.Serialization;

[ServiceContract()]
public interface IService
{
[OperationContract]
[FaultContract(typeof(ServiceException))]
string Echo(string value);
}

[Serializable]
public class ServiceException : ApplicationException, ISerializable
{
public ServiceException() { }
public ServiceException(string message) : base(message) { }
public ServiceException(string message, Exception inner) : base(message,
inner) { }
protected ServiceException(
SerializationInfo info,
StreamingContext context)
: base(info, context) { }
}

public class Service : IService
{
public string Echo(string value)
{
if (value == null)
throw new FaultException<ServiceException>(new ServiceException());
return value;
}
}

-----------
Service.svc
-----------
<% @ServiceHost Language=C# Debug="true" Service="Service"
CodeBehind="~/App_Code/Service.cs" %>

----------
Web.config
----------
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.serviceModel>
<services>
<!-- Before deployment, you should remove the returnFaults behavior
configuration to avoid disclosing information in exception messages -->
<service name="Service" behaviorConfiguration="returnFaults">
<endpoint contract="IService" binding="wsHttpBinding"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="returnFaults" >
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>

Apr 30 '07 #1
0 2331

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Vera | last post by:
Hi, I have a very annoying problem, with which I NEED HELP DESPERATELY!! It smells like a bug to me, but I'm not sure. SITUATION This description is a very much simplified version of the real...
12
by: Jose Fernandez | last post by:
Hello. I'm building a web service and I get this error. NEWS.News.CoverNews(string)': not all code paths return a value This is the WebMethod public SqlDataReader CoverNews(string Sport)...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
3
by: MIGUEL | last post by:
Hi all, I'm quite lost with how adding web references to a project creates proxy classes. I've developed a web service with two classes inside and that contains three references to three...
9
by: Gustaf | last post by:
I'm confused about structured error handling. The following piece of code is a simplification of a class library I'm working on. It works, and it does what I want, but I'm still not convinced that...
0
by: Matthew Copeland | last post by:
A little background. This is a VB.Net client application , and it uses a web reference to a web service, which has been properly refreshed. My app takes collections of two serializable...
5
by: Alias | last post by:
Hi - I'm trying to implement a custom RoleProvider based on the SqlRoleProvider. I keep receiving a an error that it can't load type 'MyRoleTest.MyRoleProvider' when trying to load my...
1
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that...
4
by: Lewis Holmes | last post by:
Hi I have the following situation in one of my asp.net pages. The user can add multiple table rows to a form by selecting a button. These rows can contain asp.net controls. When this button is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.