.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

MessageContract/XMLSerializer - Known Type not being named with its element name when passed as obje

Posted By:      Posted Date: September 27, 2010    Points: 0   Category :WCF

Okay, I've just deleted my first post since I was having issues with editting a post with codeblocks.  Trying once more.

I'm new to WCF and I am trying to write a webservice that must follow a specific XML format.  Because of this, I found that I had to drop DataContractSerializer since I must be able to use attributes.  I now have the <XMLSerializerFormat> attribute on my servicecontract for this purpose and I have laid out the schema I need by using a Class with Public Properties and the <Serializable()> attribute where appropriate.  I have one service endpoint that has several different schemas that it may accept.  I have a base class with derived classes for this purpose.  This also works well from what I can see as the test client and webservice are talking to each other just fine.  However, the client that will be using the service is non-WCF and must have the elements named specifically in order to handle them.  The problem arises when the service is serializing the derived classes.  The structure of each class works perfectly, however, the name of the element is not the name of the element I have assigned it.  It is most likely because of the way that I pass the information back and forth to the service and the fact that I do not know what the object actually is when it is passed into or out o

View Complete Post

More Related Resource Links

XmlSerializer - how to define class to not generate attributes in root element?

Hi! I have simple class that I serialize to xml file: <?xml version="1.0" encoding="utf-8"?> <MyRootElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Area="East">   <Products>     <SalesProduct Taxable="true">       <Name>Sofa</Name>     </SalesProduct>     <Product>       <Name>Television</Name>     </Product>   </Products> </MyRootElement> I don`t want have in xml file attributes xmlns:xsi and xmlns:xsd. How can I define class to not have these two attributes in xml file? I tried use XmlRoot attribute but there is no control for these two attributes. They are always generated. Regards

Analysis Service Oracle Number inconsistent Data Type for TABLE or Named Query

Dear Gurus, I'd VERY OLD PROBLEM. And I believe it addressed since 2006. When I design DataSource Views from Oracle Data Source. I found it return different oracle number data type for TABLE or NAMED QUERY   Provider Data Type Column Data Type Data Source View Data Type Oracle OLE DB Provider (OraOLEDB.Oracle.1) Table Number System.Int64   View Number System.Decimal   Named Querey Number System.Decimal Microsoft OLE DB Provider for Oracle (MSDAORA.1) Table Number System.Double   View Number System.Double   Named Query   1 System.Int64   Named Query   1.1234 System.Int64 Althought I know I can fix IT via MANUALLY EDIT DATASOURCE VIEW XML SOURCE. But I don't think this is a better solution. Is anybody have ideas ?  Wilson

'Frame' TargetType does not match type of element 'PlaceHolderControl'

Hi. I'm trying to modify ControlTemplate for WPF Frame control. I extract Frame ControlTemplate  using blend. When I try to compile my app I get the following error: 'Frame' TargetType does not match type of element 'PlaceHolderControl'. Any ideas why?

Can XmlSerializer add attributes to an element?

I'm using XmlSerializer to serialise a c# object into XML.public class Letter{        [XmlElement]        public String AccountNumber { get; set; }}which gives:<Letter><AccountNumber>12345678</AccountNumber></Letter>What I'd like to be able to do is to add a flag as an attribute to say if the particular data element is encrypted, so the XML comes out as:<Letter> <AccountNumber encrypted="true">=S2Hgd3$eDF</AccountNumber> </Letter>Is it possible to add this encrypted flag easily using the XmlSerializer? Thanks for any advice!

Sharepoint export to spreadsheet gives two extra columns in excel 2007 named as type and path, is th

When i export a list in excel 2007, it creates two extra columns named as type and path. At the same time this behaviour is not exhibited in office 2000. Is there any way to remove these two columns without using code ? Is there any configuration settings required for this, to remove it on the fly ? Thanks Ravish Verma

External Content Type - Read List Operation - "Cannot find a collection element of a supported type.


I'm trying to define External Content Type Operations for an External Content Type. I can add a Connection, Type "WCF Service" no problem. And I can define a "New Read Item Operation" using that connection.

But I can't define a "Read List Operation". I get the following error message, in the Return Parameter Configuration: "Cannot find a collection element of a supported type..." it goes on to say - see the help documentation for supported types. I can't find any help documentation on this.

I've tried returning different types in the provider web service but keep getting the same error. What are the supported types the web service can return?

The reading I've done suggests that you can connect to a non-MS web service using a connection type of "WCF Service". Is this correct? If it is what's the best soap format the web service provider should use - Doc/Literal?



'Window' not type of element 'WindowInstance' Error


I've been teaching myself WPF for about a week now, so I'm sure this is something easy.
I have made a project to contain my 'Themes' for a window.  Assembly= libThemes   Namespace= Theme_Library
The only item in this is a ResourceDictionary in the file generic.xaml (in the 'Themes' folder) with a code-behind generic.xaml.cs .
The markup of this file looks like this...


<!--  STYLES  ***********************************************************************
               *********************************************************************** -->
 <Style TargetType="{x:Type Window}" x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type theme:StandardTheme}, ResourceId=WindowStyleA}">
  <Setter Property="AllowsTransparency" Value="True" />
  <Setter Property="Wi

No element name appears after using XmlSerializer on a class implementing ICollection



I have the following issue: after serilizing my class CounterInfoCollection that implements ICollection It doesn't come up with the correct xml. I know I may solve it by using List<> instead but now that i have implemented ICollection (I did that assuming List<T> were not supported as it stated on the msdn that Arrays of two kinds including List<T> were not supported) I would like to solve it using ICollection.

Here is an example of my xml and classes:


but i obviously want CounterInfoCollection to be CounterInfo and all items wrapped around CounterInfoCollection  like:

take for example the Classes CounterInfoCollection , CounterInfo and a Holder for holding the collection


public class CounterInfoCollection : ICollection
  private ArrayList counterInfoArray = new ArrayList();

  public CounterInfo this[int index]
    get { return (CounterInfo) counterInfoArray[index]; }

  public void CopyT

SQLXML 4 - How to specify a relationship on repeating element of global complex type


I have tried to create a sample showing the issue.  Basically we have multiple elements that use a global complex type.  This complex type has a repeating element and, therefore, should have another relationship specified for it.  I've tried specifying two relationships on the "Phone" element that reference their respective parents, but that does not work.  Is this scenario supported in SQLXML using SchemaGen?

<?xml version="1.0" encoding="utf-16"?>
<xs:schema version="1.0" xmlns:xs

TreeSelector : playing with generics and type inference

create a generic way to define a selection starting from a tree of objects, the most simpler way as possible.

Let's start with the beginning...
Here is a very simple little interface defining a node of the tree, basically, a value and the references to the child nodes.

A better way to reference your wizard steps using named steps

Note: this article uses the plain vanilla but the concepts apply equally well to its popular counterpart .

By far the most common way that I see wizard steps reference in code snippets is by their index.

.NET 3.5 Adds Named Pipes Support

you want a named pipe server, all you have to do is create some instances of NamedPipeServerStream to handle each client connection. I stole the following code straight from the MSDN documentation.

UnTyped DataSets and Strongly Type DataSets

We all are use datasets as a means of carrier of data from one layer to another. Most of the time we are using weakly typed datasets. In this article I will explain the differences between weakly typed datasets and strongly type datasets

Gmail style multiple Sign-in type combo...is it possible in asp.net?


I am developing a multi-company application and want my users to give the functionality like the following to switch companies.


Is this possible? then how?

Please help


UpdatePanel is not a known element - message when upgrading to 1.0 ajax


It worked on one of my old pages.  I change the web.config, renamed all the <asp.

On some aspx page it doesn't recognize the updatepanel.  It only does on one page.  If I create a new aspx page with a different name - then it works.

Should I just create a new web project ajax - then copy all my code into there?  Or is there a way to get those old pages to recognize the new ajax controls?

Type or namespace error.


A couple of days ago I started getting an unusual behavior when compiling Website projects. I have referenced class libraries added to my bin folder that are also correctely referenced in using statements in my aspx.cs code behind. When I compile, I get the 

Error 4 The type or namespace name 'CommonClassLibrary' could not be found (are you missing a using directive or an assembly reference?) C:\Dev\Fiscal_Portal\Implementation\FMS Portal Site_new\App_Code\BLL\DataTables.cs 1 7 C:\...\FMS Portal Site_new\

The type or namespace name 'CommonClassLibrary' could not be found (are you missing a using directive or an assembly reference?)

error message that would typically be received when the dll has not been added as a reference or added in a using statement.

I can eliminate the error by adding an


Bug: Does not change column type from nvarchar to ntext


Scenario: If you create a table with a column of type nvarchar, populate it with some content and try to modify it using the WebMatrix editor, from nvarchar to ntext, it does not display any error message or warning that this is not possible. It silently saves and reverts the change, back to nvarchar. Wasted some hours on this issue as I thought my column was ntext, but in fact was still nvarchar.

Expected behavior: It should change to ntext, or if SQL CE doesn't support that, it should notify the user that no change was applied.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend