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

Serializing public interface with internal implementation works with JSON but not with XML #60523

Closed
dancojocaru2000 opened this issue Oct 17, 2021 · 1 comment

Comments

@dancojocaru2000
Copy link

Description

Serialization of an internal implementation of a public interface to XML doesn't work.

Reproduction Steps

Write a public interface, implement it with an internal class, then try to serialize an instance of the class with System.Text.Json.JsonSerializer and with System.Xml.Serialization.XmlSerializer.

Expected behavior

Both should work.

Actual behavior

XML serialization fails with:

An error occurred while trying to create an XmlSerializer for the type 'InfoferScraper.Models.Train.TrainScrapeResult'.
System.InvalidOperationException: InfoferScraper.Models.Train.TrainScrapeResult is inaccessible due to its protection level. Only public types can be proce
ssed.

Regression?

No response

Known Workarounds

No response

Configuration

.NET 5

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added area-Serialization untriaged New issue has not been triaged by the area owner labels Oct 17, 2021
@HongGit HongGit added this to Needs Triage in WCF Owned Areas Jan 13, 2022
@HongGit HongGit removed the untriaged New issue has not been triaged by the area owner label Jan 13, 2022
@HongGit
Copy link
Contributor

HongGit commented Jan 13, 2022

System.Xml.Serialization.XmlSerializer does not support this scenario. Please try DataContractSerializer.

WCF Owned Areas automation moved this from Needs Triage to Completed Mar 17, 2022
@dotnet dotnet locked as resolved and limited conversation to collaborators Apr 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Development

No branches or pull requests

3 participants