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

  • Home
  • SEARCH
  • 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 943307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:25:02+00:00 2026-05-15T22:25:02+00:00

I am aware of formatted DataContract names, as described here: http://msdn.microsoft.com/en-us/library/ms731045.aspx (Customizing Data Contract

  • 0

I am aware of formatted DataContract names, as described here: http://msdn.microsoft.com/en-us/library/ms731045.aspx (Customizing Data Contract Names for Generic Types near the bottom).

Example:

[DataContract( Name = "SearchCriteriaFor{0}", Namespace = "http://schema.mycompany.com/MyProject/" )]
public class SearchCriteria<T> { ...

This would cause SearchCriteria<Employee> to become <xs:complexType name="SearchCriteriaForEmployee"> in the generated XSD for the service. This looks a lot nicer than SearchCriteriaOfEmployeeWkD50_Xf (generic+”Of”+types+hash).

I want to do this for ServiceContracts as well. Unfortunately using the {0} syntax doesn’t work (the braces get escaped and the zero remains literal). I haven’t found any examples of how to do this, but I hoped that since it works for DataContract that it would also work for ServiceContract. Is there any way to include the type arguments as part of a custom serialization name for a ServiceContract?

However, as writing this it just occurred to me that including the type name may not even be necessary for ServiceContract at all, even though the default naming implementation does so. Is it acceptable to specify a fixed name for a generic ServiceContract? I tried it and it appears to generate the XSD correctly, but would I have to worry about any future conflicts due to this? This is an internal system and I can guarantee against any name/namespace collisions for any objects that would be used as generic type arguments.

For instance if I have a IDataStore<T>, is there any problem with:

[ServiceContract( Name = "DataStore", Namespace = "http://schema.mycompany.com/MyProject/" )]
public interface IDataStore<T> where T : MyBaseObject
{ IList<T> FindAll(); }

which would cause the resulting XSD to show http://schema.mycompany.com/MyProject/DataStore/FindAll instead of http://schema.mycompany.com/MyProject/IDataStoreOf_Employee/FindAll.

Lots of rambling here, so the real questions are in bold above.

  • 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-15T22:25:03+00:00Added an answer on May 15, 2026 at 10:25 pm

    No, there is no way to include the type arguments as part of a custom serialization name. Using Reflector, you can find the code that creates the name in System.ServiceModel.Description.NamingHelper.GetContractName. It looks like this:

    internal static XmlQualifiedName GetContractName(Type contractType, string name, string ns)
    {
        XmlName name2 = new XmlName(name ?? TypeName(contractType));
    

    The TypeName function has logic to create names for generic types and array types, but if you supply a Name in the contract it will just use that name exactly.

    I would not recommend using a fixed name for a generic contract, but it might work. Since it’s generic, I assume you have more than one instantiation of it, and IDataStore<Foo> and IDataStore<Bar> would have the same fully qualified name but would have operations of different types. As long as nothing sees both versions of the contract at once you should be okay, but if anything does see both at once it may get confused.

    Can you create a concrete subclass of the generic interface for each service? You could declare something like:

    [ServiceContract(Name = "EmployeeDataStore", Namespace = "http://schema.mycompany.com/MyProject/")]
    public interface IEmployeeDataStore : IDataStore<Employee> { }
    

    and have your service type implement that interface instead of just IDataStore<Employee>. Then, you could set the name explicitly for each type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am aware that in .NET there are three timer types (see Comparing the
I am currently aware that ASP.NET 2.0 is out and about and that there
I'm aware of things like onchange , onmousedown and onmouseup but is there a
Of course I am aware of Ajax, but the problem with Ajax is that
I'm aware of FusionCharts , are there other good solutions, or APIs, for creating
Is anyone aware of a script/class (preferably in PHP) that would parse a given
Are you aware of any tool that creates diagrams showing the branch/merge activity in
Is anyone aware of a language feature or technique in C++ to prevent a
I'm fully aware that set division can be accomplished through a series of other
I am aware of CocoaMySQL but I have not seen a Mac GUI for

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.