.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

returning arrays of custom serialized classes

Posted By:      Posted Date: September 22, 2010    Points: 0   Category :.NET Framework


I have the following class:

  [XmlRoot("person", Namespace = "http://mme.se")]
  public class Person : IXmlSerializable
    public string FirstName;

    public static XmlQualifiedName MySchema(XmlSchemaSet xs)
      string xsd =
        @"<?xml version='1.0' encoding='utf-8'?>
<xs:schema id='person' 
 <xs:complexType name='personType'>
   <xs:element name='f' type='xs:string'/>

      var schemaSerializer = new XmlSerializer( 

View Complete Post

More Related Resource Links

Smart Cleanup: Achieve More Reliable Resource Management with Our Custom C++ Classes


Managing resources in C++ is not easy. When you're unsuccessful, your app can leak all kinds of resources including file system handles, database connections, and, of course, memory. Even in garbage-collected languages like Managed C++, resource management is difficult because garbage collection only deals with memory management, not the other resources that cause performance problems.In this article, the author describes the SmartAny template library he created, which uses a policy-based approach to dynamic resource management. Readers will learn how to use the SmartAny classes and policies to ensure the proper cleanup of their resources, be they files, OS handles, or native and unmanaged objects.

Eric Niebler

MSDN Magazine June 2003

VS2010 designer problems with custom markup extensions returning FontFamily

App.xaml: <Application x:Class="CustomMarkup.App"              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"              xmlns:int="clr-namespace:CustomMarkup"              xmlns:ext="clr-namespace:ExternalMarkupExt;assembly=ExternalMarkupExt"              StartupUri="MainWindow.xaml">     <Application.Resources>         <Style x:Key="MyStyle">             <Setter                  Property="Control.FontFamily"                  Value="{ext:ExtMarkupExt {x:Static int:Resources.FONTFAMILY_NAME}}"/>         </Style>     </Application.Resources> </Application> MainWindow: <Window x:Class="CustomMarkup.MainWindow"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x=&quo

Returning custom error messages with an UserNamePasswordValidator

Ok, my head hurts from banging it against the wall. I'm new to WCF, I have searched for a solution for days, please help a desperate fellow programmer if you can :-( I have a WCF service hosted in IIS, I implemented a UserNamePasswordValidator, and it seems impossible to find a way to return a custom error message to the client when the user is not allowed in, this blows my mind. I have searched everywhere, many are asking the same question since 2006 and so far I haven't found an answer that works. If you are thinking of replying that it is not secure to return a custom error message to an unauthenticated client, please save yourself some time and don't do it. There are multiple enterprise business scenarios that this is required. Just in our organization an account could be locked out, in which case the user must be directed to the IT department to get it unlocked, it could be that the credentials are correct but the user hasn't paid their fees in which case they must be directed to the appropriate department, or it could even be that the user tried to access the service during a time of the day in which the service is not available. From searching around, I have tried doing the things below in the Validate method, however the client always receives a MessageSecurityException, which contains none of the custom messages that were originally thrown, neither in the object,

Custom Classes for Tabs Control

I want to apply a custom class to the header text of the tabs. However, the documentation indicates that all I have to do is supply a custom class to override the default. The font is being changed as expected but it appears that all of the other classes are being overridden as well. .CustomTabStyle .ajax__tab_tab { font-family: Tahoma; font-size: 10px; } . <ajax:TabContainer runat="server" CssClass="CustomTabStyle" ActiveTabIndex="0" Height="150px" Width="690px" style="margin:5px"> <ajax:TabPanel runat="server" HeaderText="Contact Information"> <ContentTemplate> Contact Information Here </ContentTemplate> </ajax:TabPanel> <ajax:TabPanel ID="TabPanel1" runat="server" HeaderText="Miscellaneous Information"> <ContentTemplate> Miscellaneous Information Here </ContentTemplate> </ajax:TabPanel> </ajax:TabContainer>

Nesting serialized classes with XmlSerializer without escaped brackets

Hi The company I work for use a state implementation based on the XmlSerializer generic class in so far that we have state classes with simple public variables and no logic which we then use the XMLSerializer to serialize in in great extend nest. For instance class A has a Class B and a class C variable, each with a state class being serialized and put into a state class of the owner class. Is there any way outside actually implementing IXmlSerializable that I can allow to include XML directly in own output xml instead of escaping it when it meets brackets in strings for instance? The deal is that since all state classes individually are serialized simple classes, I know that they contain valid XML and that that will conform to the XMLDOM even if piecing them together and manually implementing the serializers will be quite time consuming even if limiting to the CSharp framework, but the multi layer escaped structure is awfull to the eye. See this simplified example: using System.Xml; using System.Xml.Serialization; using System; using System.IO; namespace TingTester { class Program { static void Main(string[] args) { var simpleser = new XmlSerializer(typeof(LittleStateClass)); string serialized = Serialize(GetSimpleVersion(), simpleser); Console.WriteLine("Simple elements contain no escapes: {0}", !serialized.Contains("&"

Query Correlation faliure using custom Request/Reply Message Contract classes.

Hi,I have a service which is correlated by a Guid query. When I'm using designer created Message Content/Parameters feature for message definition, everithing working lika a charm. But If I define custom [MessageContract] Request/Reply classes (where request class has Guid SvcUID property for correlation), and choose'em as Message Content in the designer with proper CorrelatesOn definition of course, I have got a service exception about correlation query faliure. Have you folks tried to apply your custom [MessageContract] classes for correlated communication?

Custom membership provider not returning values from my web.config


I created a custom membership provider in my ASP.NET 4.0 web site, stored  in App_Code, and referenced in my web.config.

However, it doesn't appear to be pulling values out of web.config during initialization.

The code was taken from http://www.asp.net/general/videos/how-do-i-create-a-custom-membership-provider, and the only modifications were changing "connectionStringName" here to the name of my connection string:

    Dim ConnectionStringSettings As ConnectionStringSettings = _

The connection string always comes back as nothing in this line:

    If ConnectionStringSettings Is Nothing OrElse ConnectionStringSettings.ConnectionString.Trim() = String.Empty Then
      Throw New ProviderException("Connection string cannot be blank.")
    End If

No matter what I change the password format to in web.config, the default value here is always used:

    Dim temp_format As String = config("passwordFormat")
    If temp_format Is Nothing Then
      temp_format = "Has

Using the ProfileService with custom profile classes.



I'm not sure if this is the right place to post, but here it goes.

We've been using the asp.net Profile system for a while now, but now we want to access Profiles, Roles etc. from a WCF service.

We have a problem with the ProfileService, probably because the ProfileService doesn't know our custom profile classes (KnownType).

Here is what we have in web.config for the service:

<profile inherits="MyCompany.Web.Profile.MyAppProfile" defaultProvider="SqlProvider" enabled="true" automaticSaveEnabled="true">
        <add name="SqlProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="UserRepository" applicationName="MyApp" description="SqlProfile for MyApp"/>

Basically, we need to expose the properties in the MyComany.Web.Profile.MyAppProfile. This class inherits ProfileBase and has some pointers to other profile classes containing the actual properties we want to expose:

public class MyAppProfile : ProfileBase

Custom Controls in C# .NET

Embedding user controls in a Windows form is just like adding a simple button or text box that are already provided with .NET. These basic controls were written essentially like you code your own controls. Typically the controls you design are to be used in multiple forms or to modularize your code. These reasons help reduce the amount of code you have to type as well as make it easier for you to change your implementation. There should almost never be any reason to duplicate code because it leaves a lot of room for bugs. So, implementing functionality specific to your control in the control's source code is a good idea. This reduces code duplication as well as modularize your code, which is a good programming guideline.

Writing custom MembershipProvider

ASP.NET Membership mechanism allows to use the build-in server tables to store and retrieve user data. By default, this mechanism can only be used with SQL Server database to which Microsoft provides suitable MembershipProvider class.
Inheriting from this abstract class, developer can use his own table(-es) from any database and use any database engine other than SQL Server, like Oracle, DB2 etc.

Learning C# and OOP, Classes

This is the second lesson in a miniseries designed to teach you how to write object-oriented programs using C#. This miniseries will describe and discuss the necessary and significant aspects of object-oriented programming (OOP) using C#.

Custom Editing Behavior for DataGridView TextBox Columns

For various reasons I'm using a DataGridView instead of a ListView, and while configuring the DataGridView to look like a ListView wasn't much of a problem, there's one thing that got on my nerves, which is the behavior of textbox cells in edit mode: It is much too easy to leave the edit mode accidentally, simply by pressing the cursor keys at the wrong time. For example when the text caret is positioned behind the last character of the textbox cell content, and you press the right arrow key

Write Custom WebParts for SharePoint 2007

The popularity of SharePoint Portal Server 2003 led Microsoft to tightly integrate the next SharePoint version, Microsoft Office SharePoint Server (MOSS) 2007, with its ASP.NET 2.0 WebPart framework. This tight integration enables the ASP.NET and SharePoint developer to do a number of things that previously weren't possible

Writing Custom Web Parts for SharePoint 2007

As I mentioned in an earlier blog post, SharePoint 2007 is built on top of ASP.NET 2.0, which means you can now use ASP.NET 2.0 features (Forms Authentication, Master Pages, Membership, Site Navigation, New Data Controls, etc) when building SharePoint sites. This is true for both the new Windows SharePoint Services 3.0 version (which will be a free download) as well as Microsoft Office SharePoint Server 2007 (which costs money).

InterFaces and Abstract Classes

Link Describes About Abstraction and Interfaces In Breif

MSDN Abstract Classes Link

MSDN Reference For Abstract Clases

Returning a DataSet From a Web Services: Step-by-Step

This Example Shows how to create a webservice which returns a DataSet and a Client Which displays the DataSet in a Grid.


This Example Shows how to create a webservice which returns a DataSet and a Client Which displays the DataSet in a Grid.
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