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
XmlSerializer type constructor is triggering a "Script execution failed" #1056
Comments
@vvolkgang can you please provide a full example which recreates the problem? |
Well I have the same issue. It seems that the XmlSerializer constructor doesn't know about Roslyn Assemblies and is trying to load the Assembly? I am trying to create a XmlSerializer to serialize/deserialize an object declared in ScriptCS. It is late in the evening here on the West coast (after 6 am ;-) So I will see if I can reproduce it in a simple script. I am running a customized ScriptHost (Only adding additional Assemblies and Usings) |
Okay this seems to do the job: #r "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Runtime.Serialization.dll"
using System.Xml.Serialization;
public class TestState
{
public long Data;
public TestState()
{
Data = 0;
}
}
var serializer = new System.Xml.Serialization.XmlSerializer(typeof(TestState));
using (var tr = File.OpenRead(".\\TestState.xml"))
{
var state = ((TestState)serializer.Deserialize(tr));
Console.WriteLine("The answer: {0}", state.Data);
} Here is the TestState.xml <?xml version="1.0" encoding="utf-8"?>
<TestState>
<Data>42</Data>
</TestState> I get this:
Right after the attempt to construct the XmlSerializer. Here is a cut an past Job into the ScriptCS (0.16.1) Command line:
|
This is the same error as here dotnet/roslyn#22859 - and it's a Roslyn bug |
Hi,
My script does Xml deserialization using .NET's
XmlSerializer
, when my script creates a new instance with the type of my xml model, it triggers the following error and stops the execution (ran with logLevel debug):Note: I've created my code in a VS .NET 4.5 console app project and afterwards migrated it to scriptcs, this worked as expected before the migration.
The text was updated successfully, but these errors were encountered: