Error when Model is shared between multiple services

Please post public support tickets here. Note: for private support tickets, please send an email to support@cshtml5.com instead.
njs123
Posts: 25
Joined: Sun Dec 25, 2016 11:10 pm

Error when Model is shared between multiple services

Postby njs123 » Mon Mar 20, 2017 10:56 pm

Hi,

I have two services which use same nested model.

When I add reference to the service in the project I get following error in cshtml client application:
- There was an error reflecting property 'SharedModel1'.
1> - There was an error reflecting type 'Application6.ServiceReference1.SharedModel1'.
1> - Types 'Application6.ServiceReference1.SharedModel1' and 'Application6.ServiceReference2.SharedModel1' both use the XML type name, 'SharedModel1', from namespace ''. Use XML attributes to specify a unique XML name and/or namespace for the type.
1>


in the error list window I get following error:
Severity Code Description Project File
Error Error generating serialization assemblies. Please look in the Output pane for details. This is usually due to two serializable types having the same name. If the error persists, please contact support@cshtml5.com or ignore this error by adding the following line to your CSPROJ file: <CSharpXamlForHtml5SkipSerializationAssemblies>True</CSharpXamlForHtml5SkipSerializationAssemblies> Application6


CODE:

Code: Select all

[ServiceContract]
    [XmlSerializerFormat]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class Service1
    {
        [OperationContract]
        public Service1Model GetDataUsingDataContract()
        {
            return new Service1Model();
        }
    }


Code: Select all

   [ServiceContract]
    [XmlSerializerFormat]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class Service2
    {
        [OperationContract]
        public Service2Model GetDataUsingDataContract()
        {
            return new Service2Model();
        }
    }


Models:

Code: Select all

public class Service1Model
    {
        public SharedModel sharedModel { get; set; }
    }

public class Service2Model
    {
        public SharedModel sharedModel { get; set; }
    }

    public class SharedModel
    {
        public string Test { get; set; }
    }

Return to “Technical Support”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests