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


Post New Web Links

Problem with xmlns when I convert object to XML and XML to object back

Posted By:      Posted Date: October 05, 2010    Points: 0   Category :ASP.Net
 

Hi, I am facing a strange problem.

I have a class object which I am accessing through webservice call.

Now actually that class has a property with type of Array inside that class and that array is the array of same class object. Means in reality, I have detailed tree structure as per how data gets fill up in that class object.

This is how my XML is and my actual code.

string xml_For_Obj = "";

                xml_For_Obj = "<xml version=\"1.0\" encoding=\"utf-16\">  ";
                xml_For_Obj += "    <ComponentObject xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">";
                xml_For_Obj += "        <BundledComponents xmlns=\"http://MySite.com/ISI/OtherWebService/Components\">";
                xml_For_Obj += "            <ComponentObject>";
                xml_For_Obj += "                <SKU>Test Sku Name</SKU> ";
                xml_For_Obj += "                <SubGroup>Test SubGroup</SubGroup> ";
                xml_For_Obj += "                <Quantity>70</Quantity> ";
                xml_For_Obj += "                    <BundledComponents >";
  


View Complete Post


More Related Resource Links

Cannot convert type 'object[]' to 'byte[]'

  

I am doing this .. and i want to convert object array to byte array. How should I do that?

Object[] myVal = um.myData;

Byte[] byteArray = (Byte[])myVal;


passing object values from server to client problem

  

I get a message that x_login is not declared.  I added Dim login as String = "123", but that didn't help.  What's the problem?

code behind....

Dim Login = "123"
x_login.Value = loginID


asp....

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
   
<form id="simForm" runat="server" method='post' action='https://test.authorize.net/gateway/transact.dll'>
        <input id="HiddenValue" type="hidden" value="Initial Value" runat="server" />
        <input type='hidden' runat="server" name='x_login' id='x_login' />
        <input type='submit' runat="server" id='buttonLabel' />
 </form>

</body>
</html>


 


Problem passing custom object returned by the same webservice among two separate projects

  
I am running into casting issue with this scenario: 1. I made a custom object lets call it EmployeeObject.  2. The Employee object is wrapped in the EmployeeWebservice.  3. I have a client application project lets call it EmployeeClientApplication and a class library called DoSomeWorkClassLibrary.  Both EmployeeClientApplication and DoSomeWorkClassLibrary reference the EmployeeWebService and need to be able to pass the EmployeeObject back and forth.  4. The EmployeeClientApplication also references the DoSomeWorkClassLibrary. 5. The employeeObject in the EmployeeClientApplication becomes EmployeeClientApplication.EmployeeWebService.EmployeeObject. 6. The employeeObject in the DoSomeWorkClassLibrary becomes DoSomeWorkClassLibrary.EmployeeWebService.EmployeeObject. 7. The DoSomeWorkClassLibrary has a method called DoSomeWork that takes an EmployeeObject. When I try to pass employeeObject from EmployeeClientApplication to DoSomeWorkClassLibrary by doing something like this: DoSomeWorkClassLibrary.DoSomeWork(EmployeeClientApplication.EmployeeWebService.EmployeeObject), I am getting Unable to convert EmployeeClientApplication.EmployeeWebService.EmployeeObject to DoSomeWorkClassLibrary.EmployeeWebService.EmployeeObject.  I have searched high and low to fix this issue, I have tried changing the namespace of the reference.cs file of the webservice in

Symbol.Keyboard.KeyPad() object creation problem

  
on windows mobile 6.5 application running on Windows mobile 6 professional VGA emulator. I am trying to work on keyboard functionality like function key press events. I have coded the below line.   Symbol.Keyboard.KeyPad keypad = new Symbol.Keyboard.KeyPad();   keypad.KeyStateNotify +=new Symbol.Keyboard.KeyPad.KeyboardEventHandler(keypad_KeyStateNotify); keypad.AlphaNotify +=new Symbol.Keyboard.KeyPad.KeyboardEventHandler(keypad_AlphaNotify);   Its build successfully but raising exception at runtime. please help me out to run this code on emulator. because i don't have device.

Problem with listing records from table (object not found)

  
Hi everyone, I'm creating a website based on ASP.NET MVC 2 and SQL Server 2008 R2 Express for the database. After creating the table in database, I want to list all records in that table. For that, I use "scaffold'ing in ASP.NET to automatically generate the view file. But I encountered an error when loading that page. The error message was: [CODE] Server Error in '/' Application. Invalid object name 'dbo.Accommodations'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'dbo.Accommodations'. Source Error: Line 41:         </tr> Line 42: Line 43:     <% foreach (var item in Model) { %> Line 44: Line 45:         <tr> Source File: d:\MyProject\Views\Accommodation\Index.aspx    Line: 43 Stack Trace: [SqlException (0x80131904): Invalid object name 'dbo.Accommodations'.]    System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +2030802    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5009584 &n

Solution Deployment Problem (Administrative Framework Object Dependencies)

  
I'm having a problem with the deployment of a SharePoint workflow solution - hopefully someone can help me out.Here is the sequence of STSADM commands and their output from the console:C:\Workflows>stsadm -o deactivatefeature -name IL.SharePoint.Workflows -url http://localhost/ -forceOperation completed successfully.C:\Workflows>stsadm -o uninstallfeature -name IL.SharePoint.Workflows -forceOperation completed successfully.C:\Workflows>stsadm -o retractsolution -name IL.SharePoint.Workflows.wsp -localDeploymentSucceeded : server : The solution was successfully deployed.il.sharepoint.workflows.wsp: Operation completed with errors.C:\Workflows>stsadm -o deletesolution -name IL.SharePoint.Workflows.wspOperation completed successfully.C:\Workflows>stsadm -o addsolution -filename IL.SharePoint.Workflows.wspAn object in the SharePoint administrative framework, "SPSolutionLanguagePack Name=0 Parent=SPSolution Name=il.sharepoint.workflows.wsp", depends on other objects which do not exist.  Ensure that all of the objects dependencies are created and retry this operation.IL.SharePoint.Workflows.wsp: The Solution installation failed.Here is the related log info from the SharePoint logs:error-redacted.txtAs far as I can see, SP is attempting to insert a "SPSolutionLanguagePack" object into the configuration database, with an invalid foreign key reference

.NET Remoting Problem with Sponsor Renewal on CAO (Client Activated Object) Architecture

  
I have figured out a strange behaviour when using Client Activated Sponsorship and hope to get a hint from somebody who already got in touch with similar problems. The case is as follows: An Application is used by a server and a client. Both use (or try to use) the same objects after a user login. A lease of a session object on the server (serverSession) is initialised correctly with all of its regular remoting values in the lease for InitialLeaseTime (10) SponsorshipTimeout (5) RenewOnCallTime (10) In order to test the behaviour the values are set to seconds. It is easier to check the log every few seconds, than to wait some minutes until the Sponsorship Renewal call. If a client performs a login, the lease is according to its logged in state renewed each 10 seconds (or whatever the value is set to). So no problem so far. The lease will be alive as long as the client performs a logout, by the way it is used on a local network. Just compare the log (the renewal is firing every 10 seconds as expected): 2010-02-17 10:29:40.4338 Info Log5 SponsorObject:Renewal() 2010-02-17 10:29:50.4308 Info Log5 SponsorObject:Renewal() 2010-02-17 10:30:00.4328 Info Log5 SponsorObject:Renewal() 2010-02-17 10:30:10.4298 Info Log5 SponsorObject:Renewal() 2010-02-17 10:30:20.4318 Info Log5 SponsorObject:Renewal() 2010-02-17 10:30:30.4288 Info Log5 SponsorObject:Renewal() As soon as

Unable to cast object of type problem

  
hi I'm having a problem in this code: Public Function GetChannelList() As List(Of channel) Implements IChannelService.GetChannelList         Dim db As ChannelDataContext = New ChannelDataContext         Dim channelMatch = From channelRow In db.channels _                           Join parentChild In db.ChannelParentChildListings _                           On channelRow.channel_id Equals parentChild.parent_id _                           Order By channelRow.title Ascending _                           Select channelRow.channel_id, channelRow.title, parentChild.child,   parentChild.child_id           Return channelMatch    <-------- Error throw Unable to cast object of type 'System.Data.Linq.DataQuery`1[VB$AnonymousType_1`4[S

How to convert an IntPtr to an object in C#?

  

Hi,

I have got my hands on a managed object pointer (no its not a GCHandle) and want to convert it back to its true object. Before you ask:

  •  Yes this is unsafe
  •  GC might have moved the pointer to the managed object in the meantime rendering my pointer useless

I have ensured that at this very moment I have a valid pointer so how can I make an object out of it?

My current approach doesnot play well with the GC

   IntPtr pManagedObject = xxx
   object []arr = new object[1];
   IntPtr pArr = Marshal.UnsafeAddrOfPinnedArrayElement(arr,0);
   Marshal.WriteIntPtr(pArr,pManagedObject);

 

The problem is that WriteIntPtr does write to a managed object which is not pinned. So it can happen that I write to an arbitrary memory location which could belong to a totally different object when a GC happens betwee UnsafeAddrOf.. and the WriteIntPtr call. Since GCHandle does not allow pinning of a managed object I am running out of options. All other attempts to Marshal it e.g. as a structure are prevented by the error message that the structure contains non blitable types. Are there any options which do play well with the GC?

Yours,

  Alois Kraus

 

 

 


ListBox object Binding Problem...?

  

hii guy's

i created a ListBox and i added Engine Class object into it...so i wana display Engine Class property "Name" into ListBox..so plz tell me how can i add property name of "Name" to ListBox of Class "Engine"

Thanks,

@nagaraju

 

 


ListBox Object Binding Problem..??

  

hii guy's here i'm having small problem on Object DataBinding using ListBox.. i've a WCF class like..


[System.Runtime.Serialization.DataContract]    
	public class EngineInstanceStatus 
	{
             public string Name
		{
			get
			{
				return m_name;
			}
		}
       }

so i wana add dis class object to my ListBox.. den it'll display its property name "Name" in ListBox whenever i added this class object ot ListBox..


so plz tell me with sample how can i do this one..


Thanks,

@nagaraju


Problem in binding List<> object to Gridview

  

Dears,

We I bind a list<> object to a gridview it calls an error like this:

Error: DataBinding: 'Default2+JobsList' does not contain a property with the name 'JobId'

Hear is my markup Codes:

<asp:GridView ID="GridView1" runat="server" DataKeyNames="JobId" AutoGenerateColumns="False"
                            OnRowCommand="GridView1_RowCommand">
                            <Columns>
                                <asp:BoundField DataField="JobName" .../>
                                <asp:BoundField DataField="JobExplain" .../>
                                <asp:ButtonField CommandName="DeleteJob" .../>
                            </Columns>
</asp:GridView>


and Code behind:

public struct JobsList
    {
        public int JobId;
        public string JobName, JobExplain;
        public JobsList(int id, string name, string explain)
        {
            JobId = id;
            JobName = name;
            JobExplain = explain;
        }
    }

List<JobsList> list = new List<JobsList>();

....

list.Add(new JobsList(Approperiate Attributes..));
GridView1.DataSource = list;
GridView1.Data

XMLSerializer Problem on typcasting a deserialized object

  

Hi,

I have little understanding problem with XMLSerialiyer.

It seams to be the way, that a serialized object can not be deserialized again if serialization and deserialization are called fromassemblies which are identical, but physically located on different paths. The following code shows the deserialization:

using (FileStream fs = new FileStream(settingsPath, FileMode.Open))
{
    XmlSerializer serializer = new XmlSerializer(typeof(MySettings));
    object o = serializer.Deserialize(fs);
    instance = o as MySettings;
}

The strange part is, that the object o shows all the properties of the MySettings class (in the debugger), but when I try to assign "o as MySettings" to instance instance stays null . So actually the deserialization seems to work, but the typcasting not.

Every thing works fine as long as it is the same application that created the xml file deserializes it. But in my case, where I wrote a test, using the same assemblys (partially loaded at runtime) then the application later on will show the described faulty behaviour.

What could be the cause to my problem?

Regards
Rainer

 


XMLSerializer Problem on typcasting a deserialized object

  

Hi,

I have little understanding problem with XMLSerialiyer.

It seams to be the way, that a serialized object can not be deserialized again if serialization and deserialization are called fromassemblies which are identical, but physically located on different paths. The following code shows the deserialization:

using (FileStream fs = new FileStream(settingsPath, FileMode.Open))
{
    XmlSerializer serializer = new XmlSerializer(typeof(MySettings));
    object o = serializer.Deserialize(fs);
    instance = o as MySettings;
}

The strange part is, that the object o shows all the properties of the MySettings class (in the debugger), but when I try to assign "o as MySettings" to instance instance stays null . So actually the deserialization seems to work, but the typcasting not.

Every thing works fine as long as it is the same application that created the xml file deserializes it. But in my case, where I wrote a test, using the same assemblys (partially loaded at runtime) then the application later on will show the described faulty behaviour.

What could be the cause to my problem?

Regards
Rainer

 


Convert XML to object returns null due to unwanted string

  

Hello All,

I am facing very odd problem, when I check my xml string than in header it contain one unwanted string square [], like below, due to that casting to object is not happening. Due to that it returns null

[]<?xml version="1.0"?>

But when I remove [] and convert to object then it works fine. Any one has any idea.


WPF problem binding to an object

  

Hi: I'm having a problem binding to an object I create. I'm a newbie to WPF.  Here's my Visual Basic code, followed by my XAML.  The code runs with no errors, but nothing appears in the Label1, when I expected to see the FirstName "Shirley".  What am I doing wrong?  Thanks,  Al

Imports System.Windows

Class MainWindow
  Public Class Person
    Public FirstName As String

    Public Sub New(ByVal fName As String)
      FirstName = fName
    End Sub
  End Class

  Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As Syste

Problem in passing Json collection object from View to Action

  

Hi,

I am trying to send json data from view to controller action.  But the issue is the data is not populating in the action parameter List<Score>.

View Model:
public class Score
{
   public int QuestionId { get; set; }
   public int PrevAnswerId { get; set; }
   public int CurrAnswerId { get; set; }
   public string CurrAnswerName { get; set; }
}


Json Data look like:
[
{QuestionId:1, PrevAnswerId:3,  CurrAnswerId:3,  CurrAnswerName:'Known to Broker'},
{QuestionId:2, PrevAnswerId:7,  CurrAnswerId:7,  CurrAnswerName:'Completed'},
{QuestionId:3, PrevAnswerId:10, CurrAnswerId:10, CurrAnswerName:'Report'}
]

On window load,  I will construct the Json object using "eval()" function and do some operation in the data before its save.

On Save Click, I will call the action through the ajax call.
$.ajax({
        url: url,
        type: "GET",
        dataType: 'json',
        data: {score: ScoreJson},
     &nb

Categories: 
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