Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WCF client: Type 'System.ServiceModel.FaultException' cannot be serialized. #17700

Closed
y-lobau opened this issue Dec 9, 2019 · 3 comments
Closed
Labels
External This is an issue in a component not contained in this repository. It is open for tracking purposes.

Comments

@y-lobau
Copy link

y-lobau commented Dec 9, 2019

.NET Core SDK (reflecting any global.json):
 Version:   3.1.100
 Commit:    cd82f021f4

Runtime Environment:
12:54 PM OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.100\

Host (useful for support):
  Version: 3.1.0
  Commit:  65f04fb6db

.NET Core SDKs installed:
  2.2.401 [C:\Program Files\dotnet\sdk]
  3.0.100 [C:\Program Files\dotnet\sdk]
  3.1.100 [C:\Program Files\dotnet\sdk]

Visual Studio CE 2019 v16.4.0

I'm trying to consume WCF service. Proxy-reference was generated using VS Connected Service based on WSDL. Then when running RPC-method on Reference class im getting the following inner exception below. The call to service is fine - i can see it in fiddler.

Type 'System.ServiceModel.FaultException' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. Alternatively, you can ensure that the type is public and has a parameterless constructor - all public members of the type will then be serialized, and no attributes will be required.

I checked FaultException class - it's public with parameterless constructor:
...packages\system.servicemodel.primitives\4.7.0\ref\netcoreapp2.1\System.ServiceModel.Primitives.dll
Looks as a bug to me.

@y-lobau y-lobau changed the title Type 'System.ServiceModel.FaultException' cannot be serialized. WCF client: Type 'System.ServiceModel.FaultException' cannot be serialized. Dec 9, 2019
@Pilchie Pilchie added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Dec 9, 2019
@blowdart
Copy link
Contributor

blowdart commented Dec 9, 2019

@mconnew does this belong in your repo?

@blowdart blowdart removed the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Dec 9, 2019
@mkArtakMSFT mkArtakMSFT added the External This is an issue in a component not contained in this repository. It is open for tracking purposes. label Dec 9, 2019
@mconnew
Copy link
Member

mconnew commented Dec 9, 2019

This is being tracked in dotnet/wcf#3984.
As mentioned in that issue, passing a FaultException, (or any exception for that matter) isn't something that's generally done in WCF services. It's a bit of an anti-pattern as exceptions are meant for code flow control and not data objects. If you throw a FaultException from a service, it gets turned into a SOAP Fault message and WCF does not serialize the FaultException itself. On the client side a FaultException is instantiated with the details from the SOAP Fault and then thrown. Having said that, we do plan to support it because even though it's not a recommended way to do things, strictly speaking there's not a technical reason to not support it, it's just a bit of a strange way to do things.
@blowdart, can you close this issue (I don't have permission to close it) as it's being tracked in the WCF repo.

@blowdart
Copy link
Contributor

blowdart commented Dec 9, 2019

Closing as external.

@blowdart blowdart closed this as completed Dec 9, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Jan 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
External This is an issue in a component not contained in this repository. It is open for tracking purposes.
Projects
None yet
Development

No branches or pull requests

5 participants