Re: LINQ and XML for compact framework



On May 1, 2:09 pm, "Jon Skeet [C# MVP]" <sk...@xxxxxxxxx> wrote:
On May 1, 1:27 pm, Wan <luo...@xxxxxxxxx> wrote:

Ok, I am not sure if you complie it from command line will help to see
the problem.

It would if you would tell us how the program behaved differently to
how you expected - without referring to the debugger.

 As the program was complied with no errors.

Yes, many short but complete programs do.

I expect this piece of code can go to the XML I pasted, and find the
element as well as changing the value.  However, it didn't changed
value.  even though it found the XML file, loaded XML, ran the LINQ
statement.  Finally when I check the value of "IEnumerable<XElement>
msgs" by watching this variable.  It will give me such error message:

Yes, so you've said. That's in the debugger. Now, can you show a
program which produces output X when you expect output Y, without
having to break and look at the debugger? If it's *only* an issue with
the debugger, I'm unlikely to be able to help. If the program isn't
working as expected however, then please specify in what way that is
the case.

Here's an example of what I mean:

<sample post>
Problem: Addition with large numbers appears not to work.

I'm having trouble with addition when it comes to large integers

Program:
using System;

class Test
{
    static void Main()
    {
        int i = 2147483647;
        Console.WriteLine("i={0}", i);
        Console.WriteLine("i+1={0}", i+1);
    }

}

Expected output:
i=2147483647
i+1=2147483648

Actual output:
i=2147483647
i+1=-2147483648

Note that the result is negative. Why?
</sample post>

At this point:
a) I can easily compile and run the code
b) I can understand the problem
c I can verify that I see the problem too
d) I can easily change the code to try to fix it

Now obviously that's a trivial example - but it's a good model. While
you can only express what's wrong in terms of watching a variable in
the debugger, I'm inclined to put the issue down to a debugger
problem.

Jon

The original XML file:

<?xml version="1.0"?>
<ArrayOfMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
<Message>
<IMEI xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">35340401169569600</IMEI>
<MessageText xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">hi</MessageText>
<MessageID xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">14722</MessageID>
<UserID xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">12984</UserID>
<SenderName xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">HardCode Test </SenderName>
<TimeStamp xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">2008-04-29T16:26:36.097</TimeStamp>
<MessageStaus xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">3</MessageStaus>
</Message>
</ArrayOfMessage>



After run the program I wrote, I expect the XML to become:
<?xml version="1.0"?>
<ArrayOfMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
<Message>
<IMEI xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">35340401169569600</IMEI>
<MessageText xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">hi</MessageText>
<MessageID xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">14722</MessageID>
<UserID xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">12984</UserID>
<SenderName xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">HardCode Test </SenderName>
<TimeStamp xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">2008-04-29T16:26:36.097</TimeStamp>
<MessageStaus xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">5</MessageStaus>
</Message>
</ArrayOfMessage>

The last element <MessageStaus></MessageStaus> should change its
value.

Actual Output has nothing changed. However, if I created a normal
framework console application project. And copy, paste this code, it
will do the job. That's why I want to ask how to use LINQ to modify
XML in compact framework.


Wan





.



Relevant Pages

  • Re: Access violation in MSXML.dll ???
    ... Are you building your DLL with fully debug or with retail? ... the code gets executed just enough for the debugger to be able to figure out ... Below is the destructor for XML module: ...
    (microsoft.public.windowsce.embedded)
  • Re: Running ASP.NET 2.0 app on IIS on XP from VS.NET 2005 B1
    ... no I didn't write any XML that I know of. ... I did was publish a project that works in the debugger to local host from VS ... >> ASP.NET project to start in IIS running on an XP development machine. ... Error processing resource ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: MSXML IXMLDomDocument Load problem
    ... like all you have to do is to add the exception ID to the list of known ... exceptions in EVC. ... debugger, allowing you some more debugging facilities. ... > XML/missing XML file/etc... ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Cdata, C# and XML
    ... different assigns (they are stopped in the debugger). ... It could be operating systems settings, ... I am using Windows Forms and .NET 1.1. ... "complete" program is just simply using the method to read the XML. ...
    (microsoft.public.dotnet.languages.csharp)

Loading