none
Exception when Operation contract returns AssemblyName RRS feed

  • Question

  • I have a simple service with an operation contract which shall return the executings assembly's AssembyName, code snippet:
    Assembly.GetExecutingAssembly().GetName().

    The client throws a System.ServiceModel.CommunicationException when called, message:
    The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9810006'.

    Inner exception System.Net.Sockets.SocketException with message:
    An existing connection was forcibly closed by the remote host

    If I change the return value from AssemblyName to string and the snippet to Assembly.GetExecutingAssembly().GetName().ToString() then all is good

    AssemblyName class is marked as serializable so I don't understand why this is not working

    Friday, July 20, 2018 8:56 AM

Answers

  • It looks like, from documentation, that it can't be deserialized ... which is probably where your problem is.

    https://msdn.microsoft.com/en-us/library/system.runtime.serialization.serializationinfo.assemblyname

    From that doc, it says:

    The AssemblyName is the same as the value returned by FullName property of the assembly of the containing type. This is the assembly name that the formatter uses when serializing type information for this object.

    The assembly name contains the name of the assembly, version, culture, and some security information about the object.

    Users who are changing the type being serialized (for example, to send a proxy for a particular type) will set the value of this property.

    System_CAPS_cautionCaution

    Do not use this property during deserialization because the value of this property is undefined.


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    • Marked as answer by EuroEager Sunday, July 22, 2018 7:53 AM
    Friday, July 20, 2018 2:14 PM
  • I agree ... it does seem strange.

    Do you actually need all the additional information contained in that string (version, culture, etc), or did you only want the name of the Assembly? If all you care about is the name, you can get that with:

    Assembly.GetExecutingAssembly().GetName().Name


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    • Marked as answer by EuroEager Sunday, July 22, 2018 5:25 PM
    Sunday, July 22, 2018 4:26 PM

All replies

  • It looks like, from documentation, that it can't be deserialized ... which is probably where your problem is.

    https://msdn.microsoft.com/en-us/library/system.runtime.serialization.serializationinfo.assemblyname

    From that doc, it says:

    The AssemblyName is the same as the value returned by FullName property of the assembly of the containing type. This is the assembly name that the formatter uses when serializing type information for this object.

    The assembly name contains the name of the assembly, version, culture, and some security information about the object.

    Users who are changing the type being serialized (for example, to send a proxy for a particular type) will set the value of this property.

    System_CAPS_cautionCaution

    Do not use this property during deserialization because the value of this property is undefined.


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    • Marked as answer by EuroEager Sunday, July 22, 2018 7:53 AM
    Friday, July 20, 2018 2:14 PM
  • Thanks

    Without reflecting too much on it I find it strange that it is serializable without beeing de-serializable...

    Sunday, July 22, 2018 7:53 AM
  • I agree ... it does seem strange.

    Do you actually need all the additional information contained in that string (version, culture, etc), or did you only want the name of the Assembly? If all you care about is the name, you can get that with:

    Assembly.GetExecutingAssembly().GetName().Name


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    • Marked as answer by EuroEager Sunday, July 22, 2018 5:25 PM
    Sunday, July 22, 2018 4:26 PM
  • He he, no I don't need the info at all, I am just extremely curious sometimes:)
    Sunday, July 22, 2018 5:24 PM