Click here to Skip to main content
15,918,742 members
Home / Discussions / C#
   

C#

 
AnswerRe: DataGridviewRow - Make it invisible . Pin
ATCsharp5-May-09 5:15
ATCsharp5-May-09 5:15 
Questionimporting from excel Pin
Solly745-May-09 4:38
Solly745-May-09 4:38 
AnswerRe: importing from excel Pin
fly9045-May-09 5:11
fly9045-May-09 5:11 
GeneralRe: importing from excel Pin
Solly745-May-09 5:15
Solly745-May-09 5:15 
AnswerRe: importing from excel Pin
riced5-May-09 6:57
riced5-May-09 6:57 
GeneralRe: importing from excel Pin
Solly745-May-09 11:54
Solly745-May-09 11:54 
GeneralRe: importing from excel Pin
riced5-May-09 22:16
riced5-May-09 22:16 
QuestionCustom Classes in web services Pin
BASONJS5-May-09 4:07
BASONJS5-May-09 4:07 
Hi all,

I have a problem with custom classes in web services. The scenario is as follows:

I have created custom classes for use with my environment. We will take as an example, class student and class teacher which are in the package MyPackage.Data. These are being serialised at location A, passed to the web service and then sent to location B. While at the web service, the object is deserialised in order to extract info about the object to keep a log of what is going through. When the object is deserialised in the web service and then reserialised to send to location B (this also happens when creating a new object at the web service and sending it out to a location), the type of the object turns into MyWebservice.Student instead of MyPackage.Data.Student.

I get exceptions like: "Cannot cast object of type MyWebservice.Student to MyPackage.Data.Student".

I am guessing this is being taken from the reference file which is autogenerated on instantiation of a web service. An example of this auto generated code is shown below for the Student class

/// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3053")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="MyPackage.Date")]
    public partial class Student{
        
        private string Name;
        
        /// <remarks/>
        public string Name{
            get {
                return this.name;
            }
            set {
                this.name= value;
            }
        }
        
    }


Now for this I used a work around, writing an alternate constructor for each class which takes an object of type MyWebservice.Student for example and creates a new instance of of MyPackage.Data.Student and sets all attributes to the attributes of the MyWebservice.Student object. An example is shown below:

public Starter(MyWebservice.Student webStudent)
{
    this.name  = webStudent.Name;
}


This works but is neither pleasant nor viable as a final solution. Can anybody please shed any light on how not to use the generated code of the web service or remove it completely or why this is happening.

Thanks a lot for your time and cooperation, any help is highly appreciated
QuestionAdding a WebReference using WSE 3.0 Pin
ATCsharp5-May-09 3:42
ATCsharp5-May-09 3:42 
Questioni got some xml questions Pin
Miroslav885-May-09 3:25
Miroslav885-May-09 3:25 
GeneralRe: i got some xml questions Pin
harold aptroot5-May-09 3:33
harold aptroot5-May-09 3:33 
GeneralRe: i got some xml questions Pin
Miroslav885-May-09 9:43
Miroslav885-May-09 9:43 
GeneralRe: i got some xml questions Pin
harold aptroot5-May-09 10:57
harold aptroot5-May-09 10:57 
AnswerRe: i got some xml questions Pin
led mike5-May-09 4:31
led mike5-May-09 4:31 
QuestionConvert Variant in VB to C# Pin
klaydze5-May-09 3:22
klaydze5-May-09 3:22 
AnswerRe: Convert Variant in VB to C# Pin
Le centriste5-May-09 5:19
Le centriste5-May-09 5:19 
GeneralRe: Convert Variant in VB to C# Pin
klaydze6-May-09 2:20
klaydze6-May-09 2:20 
QuestionVariant in VB to C# Pin
klaydze5-May-09 3:13
klaydze5-May-09 3:13 
AnswerRe: Variant in VB to C# Pin
Simon P Stevens5-May-09 4:39
Simon P Stevens5-May-09 4:39 
GeneralRe: Variant in VB to C# Pin
klaydze6-May-09 2:17
klaydze6-May-09 2:17 
GeneralRe: Variant in VB to C# Pin
Simon P Stevens6-May-09 2:57
Simon P Stevens6-May-09 2:57 
GeneralRe: Variant in VB to C# Pin
klaydze6-May-09 3:51
klaydze6-May-09 3:51 
GeneralRe: Variant in VB to C# Pin
Simon P Stevens6-May-09 4:38
Simon P Stevens6-May-09 4:38 
GeneralRe: Variant in VB to C# Pin
klaydze6-May-09 4:58
klaydze6-May-09 4:58 
GeneralRe: Variant in VB to C# Pin
Simon P Stevens6-May-09 6:14
Simon P Stevens6-May-09 6:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.