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

System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly throws NullReferenceException from native host #1518

Closed
AArnott opened this issue Jan 9, 2020 · 4 comments
Assignees
Milestone

Comments

@AArnott
Copy link
Contributor

AArnott commented Jan 9, 2020

When hosting .NET Core in a native application, Assembly.GetEntryAssembly() returns null. The System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly(Type, string, out XmlSerializerImplementation) method is not prepared for this and throws NullReferenceException.

if ((string.IsNullOrEmpty(serializerPath) || !File.Exists(serializerPath)) && !string.IsNullOrEmpty(Assembly.GetEntryAssembly().Location))

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-Serialization untriaged New issue has not been triaged by the area owner labels Jan 9, 2020
@StephenBonikowsky
Copy link
Member

@AArnott Thanks for reporting this!

@StephenBonikowsky StephenBonikowsky removed the untriaged New issue has not been triaged by the area owner label Jan 28, 2020
@StephenBonikowsky StephenBonikowsky added this to the 3.1.x milestone Jan 28, 2020
@ericstj
Copy link
Member

ericstj commented Jun 4, 2020

Looks to me like this was assuming GetEntryAssembly() would never return null, but it does in this case as mentioned here: #25027 (comment)

A fix for this would be to handle null, and fall back to something like AppContext.BaseDirectory instead. Perhaps just replace this with AppContext.BaseDirectory.

@vladimir-cheverdyuk-altium

I have exactly the same problem

@HongGit HongGit modified the milestones: 3.1.x, 6.0.0 Aug 12, 2020
@StephenMolloy
Copy link
Member

Looks like this was already fixed by #40598. But #52429 also reworks this area of code to improve experiences here. Either way, I believe this issue has been addressed.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 19, 2021
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

7 participants