Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6171285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:11:10+00:00 2026-05-23T23:11:10+00:00

I have a WCF operation MyGetVersion() that returns a System.Version. When debugging a call

  • 0

I have a WCF operation MyGetVersion() that returns a System.Version. When debugging a call to it from a Silverlight service reference, I verified that the service returns the correct System.Version object. In the service reference, the auto-generated method:

       public System.Version EndMyGetVersion(System.IAsyncResult result) {
            object[] _args = new object[0];
            System.Version _result = ((System.Version)(base.EndInvoke("MyGetVersion", _args, result)));
            return _result;
        }

raises the exception:

Attempt by method ‘DynamicClass.ReadVersionFromXml(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.XmlObjectSerializerReadContext, System.Xml.XmlDictionaryString[], System.Xml.XmlDictionaryString[])’ to access method ‘System.Version..ctor()’ failed.

I had to turn on the “break on CLR exception” helper to see this. Otherwise, it is a TargetInvocationException. The System.Version() constructor is public as far as I can tell. What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:11:10+00:00Added an answer on May 23, 2026 at 11:11 pm

    The problem is that the constructor of System.Version is public in the .NET Framework, but it’s not in Silverlight (it’s internal, according to Reflector). So while the type is serializable in the full framework, it’s not in Silverlight, and the Add Service Reference tool should have replaced it with an equivalent type in SL – this is a bug in the tool (I’ll report it to the product team, thanks for finding it).

    As workarounds, I’d suggest to use a “surrogate” type for Version, and use it in your service contract for data transfer only:

    [DataContract]
    public class VersionDTO
    {
        [DataMember]
        public int Major { get; set; }
        [DataMember]
        public int Minor { get; set; }
        [DataMember]
        public int Build { get; set; }
        [DataMember]
        public int Revision { get; set; }
    
        public VersionDTO(Version version) {
            this.Major = version.Major;
            this.Minor = version.Minor;
            this.Build = version.Build;
            this.Revision = version.Revision;
        }
    }
    
    [ServiceContract]
    public interface ITest
    {
        [OperationContract]
        VersionDTO GetVersion();
    }
    

    Another option, given the issue you mentioned in the comment, would be to replace the reference to the Version class in the generated proxy for Silverlight with a class which is equivalent to it. The class below can be used to deserialize a Version object in SL from .NET.

        [DataContract(Name = "Version", Namespace = "http://schemas.datacontract.org/2004/07/System")]
        public class SLVersion
        {
            [DataMember(Order = 1, Name = "_Build")]
            public int Build { get; set; }
            [DataMember(Order = 2, Name = "_Major")]
            public int Major { get; set; }
            [DataMember(Order = 3, Name = "_Minor")]
            public int Minor { get; set; }
            [DataMember(Order = 4, Name = "_Revision")]
            public int Revision { get; set; }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF service that I have to reference from a .net 2.0
I have a WCF service operation that accepts a data contract parameter of custom
I have a WCF Web Service which is referenced from a class library. After
I have some WCF methods that are used to transmit information from a server
I have a WCF service, hosted in IIS 7.0 that needs to run database
I have a WCF Service operation which takes an object as a parameter. This
I have WCF service to get users from the ActiveDirectory. I receive parameter from
Background This question is in two parts. I have a one-way WCF operation hosted
I have a wcf application hosted in a windows service running a local windows
I have a WCF service hosted for internal clients - we have control of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.