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

XmlSerializer type constructor is triggering a "Script execution failed" #1056

Open
vvolkgang opened this issue Jun 24, 2015 · 4 comments
Open

Comments

@vvolkgang
Copy link

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):

DEBUG: Finished execution
ERROR: Script execution failed: The filename, directory name, or volume label syntax is incorrect. (Exception from HRESULT: 0x8007007B).
DEBUG: Terminating packs

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.

@adamralph
Copy link
Contributor

@vvolkgang can you please provide a full example which recreates the problem?

@RogerMostad
Copy link

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)

@RogerMostad
Copy link

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:

The filename, directory name, or volume label syntax is incorrect. (Exception from HRESULT: 0x8007007B)

Right after the attempt to construct the XmlSerializer. Here is a cut an past Job into the ScriptCS (0.16.1) Command line:

> #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));
The filename, directory name, or volume label syntax is incorrect. (Exception from HRESULT: 0x8007007B)
> using (var tr = File.OpenRead(".\\TestState.xml"))
* {
*     var state = ((TestState)serializer.Deserialize(tr));
*     Console.WriteLine("The answer: {0}", state.Data);
* }
(3,29): error CS0103: The name 'serializer' does not exist in the current context
>

@filipw
Copy link
Member

filipw commented Oct 30, 2017

This is the same error as here dotnet/roslyn#22859 - and it's a Roslyn bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants