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

Desktop throws a TypeLoadException when StreamingContext is a typeforward to mscorlib and using any of the serialization event attributes #20795

Closed
safern opened this issue Mar 27, 2017 · 8 comments

Comments

@safern
Copy link
Member

safern commented Mar 27, 2017

If an assembly is built against netstandard and run it against netfx (desktop) and it has a type marked as Serialized and this types have any of the event methods that use either OnDeserializedAttribute, OnSerializingAttribute, OnSerializedAttribute, and OnDeserializingAttribute it would throw an exception like this one:

Type <type name> in assembly <assembly name> has method <method name> with an incorrect signature for the serialization attribute that it is decorated with

This would happen even if the method follows the guidelines stated in the msdn documentation:

To use the OnSerializingAttribute, the method must contain a StreamingContext parameter.

We are currently hitting this issue on the System.Runtime.Serialization.Formatters.Tests that have a type with this characteristics (source code) when the test is built against netstandard and we run it against netfx.

After investigating with @weshaggard he found out that there a bug in the methodtablebuilder.cpp when verifying the signature for this method (requiring a StreamingContext parameter) it doesn't follow the typeforwards correctly on the case it was defined on a shim like in the case of netstandard that is a typeforward to mscorlib so it throws an exception that the method signature is bad.

cc: @jkotas @stephentoub

@stephentoub
Copy link
Member

stephentoub commented Apr 12, 2017

@safern, should this issue be moved to coreclr?

@jkotas
Copy link
Member

jkotas commented Apr 12, 2017

This is .NET Framework bug. It should be moved to internal TFS where .NET Framework bugs are tracked.

@safern
Copy link
Member Author

safern commented Apr 12, 2017

This is .NET Framework bug. It should be moved to internal TFS where .NET Framework bugs are tracked.

Indeed it is a .NET Framework bug where the VM doesn't follow the typeforwards correctly.

@safern, should this issue be moved to coreclr?

We decided to open it here (github and corefx), so that a decision is made towards if we want to support binary serialization on 2.0 and document this bug or if we want to push that to 2.1 when this bug gets fixed on the next Full Framework release.

@stephentoub
Copy link
Member

so that a decision is made towards if we want to support binary serialization on 2.0

I don't understand this comment. Can you elaborate? What's not supported with .NET Core 2.0 that would need to be documented?

@safern
Copy link
Member Author

safern commented Apr 12, 2017

We currently don't support building against netstandard and running on netfx a library/application that uses binary serialization. In theory we support this but due to this bug in the VM our customers will get a TypeLoadException when following this path.

They would have to have to different binaries of their library/application for this to work (one built against netcoreapp and one against netfx)

Does this makes it clearer?

@stephentoub
Copy link
Member

Ah. In that case if you're looking for a GitHub tracking issue related to standard, wouldn't this be better in the dotnet/standard repo (in addition to whatever bug you open in TFS for desktop)? It seems like there's zero action item here for core, and any documentation would be related to standard and desktop, not core.

@safern
Copy link
Member Author

safern commented Apr 12, 2017

In that case if you're looking for a GitHub tracking issue related to standard, wouldn't this be better in the dotnet/standard repo (in addition to whatever bug you open in TFS for desktop)?

Sounds good, I can take care of that.

@safern safern closed this as completed Apr 12, 2017
@safern
Copy link
Member Author

safern commented Apr 12, 2017

Opened: dotnet/standard#300 and 407239 on TFS.

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.0.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants