Search

Using custom FaultContract object containing System.Exception causes 'Add Service Reference' to fail by Mugambo

Active

1
0
Sign in
to vote
Type: Bug
ID: 776214
Opened: 1/10/2013 3:44:33 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
I just noticed something particular. I have an internal service which is published through basicHttpBinding for which metadata is enabled. I also included a mex endpoint for http. We use Visual Studio 2012 & C#.

Just recently we noticed that we were unable to succesfully add a service reference to this service in our other projects. All that it would generate was the first custom exception we included through a FaultContract (actually, there was only 1 type). if I'd add a simple web reference it would work correctly as well. Also, the WcfClient.exe had no problems either in loading the services. Just VS.NET add service reference wouldn't work.

In the service this exception inherits from Exception and is marked as serializable. That's all you're supposed to do, no?

Anyway, this had me baffled. If I remove the FaultContract for this custom exception everything works fine. I can add a service reference, no problem. But is there a way I can still have my custom exceptions? Is this a known problem?
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

Visual Studio 2012

Steps to reproduce

1) Create WcfServiceLibrary project with code:

using System;
using System.ServiceModel;

namespace WcfServiceLibrary1
{
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        [FaultContract(typeof(MyException))]
        void DoWork();
    }

    public class Service1 : IService1
    {
        public void DoWork()
        {
        }
    }

    [Serializable]
    public class MyException : Exception
    {

    }
}

2) Create ConsoleApplication project and use "Add Service Reference".

Product Language

Russian

Operating System

Windows 7 SP1

Operating System Language

Russian

Actual results

In hidden file Reference.cs

//------------------------------------------------------------------------------
// <auto-generated>
//     Этот код создан программой.
//     Исполняемая версия:4.0.30319.17929
//
//     Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
//     повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------

namespace ConsoleApplication1.ServiceReference1 {
    
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    public class MyException {
    }
}

and in ConsoleApplication App.config don't add information about service endpoint.

Expected results

Full code for service client in file Reference.cs and information about it's endpoints in App.config file.
File Attachments
File Name Submitted By Submitted On File Size  
WcfServiceLibrary1.zip 1/11/2013 52 KB
Sign in to post a comment.
Posted by Microsoft on 4/26/2013 at 11:47 AM
Thanks for your feedback. This is a known limitation of WCF and at this point we have decided not to fix this considering the risk of fixing and introducing regression. We will continue to monitor customer hits on this and may increase priority based on it.
Posted by Microsoft on 1/10/2013 at 9:05 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 1/10/2013 at 3:54 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.