.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

serializing generic classes?

Posted By:      Posted Date: August 30, 2010    Points: 0   Category :.NET Framework
  heys all i'm rreally confused with where the serialization is in my web service. i've included a fully working short example (if you try to run it you will see the error message   Types 'WebService1.My.Abstract.Result`1[WebService1.My.CheckEmailResult.EnumError]' and 'WebService1.My.Abstract.Result`1[WebService1.My.CheckUserNameResult.EnumError]' both use the XML type name, 'ResultOfEnumError', from namespace 'http://tempuri.org/'. Use XML attributes to specify a unique XML name and/or namespace for the type.       Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.ComponentModel ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. ' <System.Web.Script.Services.ScriptService()> _ <System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _ <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ <ToolboxItem(False)> _ Public Class Service1 Inherits System.Web.Services.WebService <WebMethod()> _ Public Function HelloWorld() As String Return "Hello World" End Function <WebMethod()> _ Public Function CheckUserName() As My.CheckUserNameResult Return New My.CheckUserNameResult End Function <WebMethod()> _ Public Function CheckEmail() As My.CheckEmail

View Complete Post

More Related Resource Links

Confusion about web service return types (classes, generic list)?


I have confusion about web service return types? Can a webservice return a genelist? ex: List(Of Employees)

I have searched threads in this forums but got confused, some say 'yes' some say 'no'.

If I mark the class as Serizable will that be enough to return a generic list?


Creating a Generic Entity Framework 4.0 Repository

With .NET 4.0 right around the corner, I thought it would be cool to download Visual Studio 2010 beta 2 and start playing around with the next release of Entity Framework.

The initial release of Entity Framework came with a great deal of criticism. To make matters worse, there was a large uproar when it was rumored that Microsoft would be abandoning LINQ to SQL, in favor of Entity Framework. This was because, at the time, many developers felt Entity Framework was an inferior technology to LINQ to SQL. To set things right, Microsoft proactively moved forward with improving Entity Framework, in time for the 4.0 release of the .NET Framework. This is good news because my initial impressions, so far, have been nothing but positive.

A Generic Dialog ViewModel

I worked on a wpf viewmodel for dialogs, because it seemed strange to me that you needed for instance windows forms dialogs to open or save files in wpf. So I set about creating my own wpf dialogs. After creating the dialog viewmodels there still remained a small issue with the library and also I didn't have much time to write an article about it. I however published the library containing the viewmodels for dialogs with another article on my blog

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#.

InterFaces and Abstract Classes

Link Describes About Abstraction and Interfaces In Breif

MSDN Abstract Classes Link

MSDN Reference For Abstract Clases

Format Generic List Bound to Gridview


I have a generic list of a custom type. The custom type has a string and double.

I'm binding the list to a gridview and it outputs everything fine.

I'm trying to format the double column into a currency format. It is in a template field as I'm calculating a running total. I pass the value to a function that returns a double and adds the current value to a running total which I will show in the footer.

The format is not changing to currency as expected when using String.Format("{0:c}", GetTotal(Convert.ToDouble(Eval("Amount"))))

Any ideas on what might be going on and how to fix this?


Need Syntax To Make Results of LINQ Union Return Non-Generic Type



I have the below SQL which works just fine:

SELECT     Message, CreateDate, AccountId, AlertTypeId
FROM       dbo.Alerts
SELECT     TOP (100) PERCENT Status, CreateDate, AccountId,
                          (SELECT     10 AS Expr1) AS AlertTypeId
FROM         dbo.StatusUpdates
WHERE AccountId = PassedInParameter

I have been going about trying to convert the above into a LINQ method and am having problems with return types.
As the above SQL illustrates, I am querying two distinct LINQ tables - Alerts and StatusUpdates -
and then attempting to perform a Union on them. In order to do the union in LINQ, I have to have agreeing types. So, I
am using "var" to make the results of "alerts" and "updates" generic before the union.  

public IList GetStatusUpdatesAsAlertsByAccountId<T>(Int32 accountId)
            using (WorkbookDataContext dc = _conn.GetCont

Serializing XML and storing as XML in Database


Hi All,

I know this may sound a daft question but I'm wanting to save Serialized XML into a databse but for the life of me I cant do it.

So far I have my class

public static void SerializeToXML(Candidate candidate)
            XmlSerializer serializer = new XmlSerializer(typeof(Candidate));
            TextWriter textWriter = new StreamWriter(@"C:\movie.xml");            
            serializer.Serialize(textWriter, candidate);

This basically save the serialized properties in the Candidate class into the movie.xml file which is great but I want it to return XML (so it can be re-used) so I can store the XML in the XML database field

Any help would be greatly appreciated



A generic error occurred in GDI+.



I'm getting this error on the yellow screen and I have no idea what to do with it, or where to start:

[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) +377630
NopSolutions.NopCommerce.BusinessLogic.Media.PictureManager.GetPictureUrl(Picture picture, Int32 targetSize, Boolean showDefaultPicture) in F:\Temp\Test\nopCommerce 1.60\Libraries\Nop.BusinessLogic\Media\PictureManager.cs:396
NopSolutions.NopCommerce.BusinessLogic.Media.PictureManager.GetPictureUrl(Picture picture, Int32 targetSize) in F:\Temp\Test\nopCommerce 1.60\Libraries\Nop.BusinessLogic\Media\PictureManager.cs:180
NopSolutions.NopCommerce.Web.Administration.Modules.CategoryInfoControl.BindData() in F:\Temp\Test\nopCommerce 1.60\NopCommerceStore\Administration\Modules\CategoryInfo.ascx.cs:63
NopSolutions.NopCommerce.Web.Administration.Modules.CategoryInfoControl.Page_Load(Object sender, EventArgs e) in F:\Temp\Test\nopCommerce 1.60\NopCommerceStore\Administration\Modules\CategoryInfo.ascx.cs:99
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14

A generic error occurred in GDI+


I am getting this error at this line in my code: ImgThnail.Save(ThumbnailPath, Img.RawFormat);

Here is the entire code :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Drawing;

    public static class Thumb2
        public static string createThumb(this HttpServerUtility srv, string endPath, string tempPath, int relSize)

            string ThumbnailPath = srv.MapPath("~\\Thumb\\" + endPath);
            string dimensions;
            using (System.Drawing.Image Img = System.Drawing.Image.FromFile(srv.MapPath("~\\" + tempPath))) 
                Size ThumbNailSize = NewImageSize(Img.Height, Img.Width, relSize);
                dimensions = Img.Width.ToString() + " x " + Img.Height.ToString();
                using (System.Drawing.Image ImgThnail = new Bitmap(Img, ThumbNailSize.Width, ThumbNailSize.Height))
                    ImgThnail.Save(ThumbnailPath, Img.RawFormat);
            return dimensions;
        private static Size NewImageSize(int OriginalHeight, int OriginalWidth, double FormatSize)
            Size NewSize;
            double tempval;
            bool landscape;

Relation between classes in c# with class diagrams



Can anyone provide me an example of one to one and one two many relationship between classes in c# with class diagram and explationation.

Basic Instincts: Generic Co- and Contravariance in Visual Basic 2010


Dig into the new co- and contravariance features coming in Visual Studio 2010. Binyam Kelile provides hands-on Visual Basic examples to explain how they provide more flexibility when working with generic interfaces and delegates.

Binyam Kelile

MSDN Magazine March 2010

Toolbox: Serializing objects, Scott Allen's blog, Site Performance, and more


Serialize and Deserialize Fixed Length and Delimited Files, Scott Allen's blog, inspecting Web Pages, and more.

Scott Mitchell

MSDN Magazine August 2008

Foundations: Extending the WPF Animation Classes


Learn what the WPF Animation Classes can do, what they can't, and how to extend them.

Charles Petzold

MSDN Magazine July 2007

CLR Inside Out: New Library Classes in "Orcas"


The next version of Visual Studio currently code-named "Orcas"supports advanced encryption algorithms, Elliptic curve cryptography, big integers, and other security enhancements. The CLR team explains.

Mike Downen, Inbar Gazit, and Justin Van Patten

MSDN Magazine April 2007

.NET Matters: Restart Manager and Generic Method Compilation


This month Stephen Toub answers questions pertaining to the Windows Vista Restart Manager API and generic method compilation.

Stephen Toub

MSDN Magazine April 2007

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