473,769 Members | 3,305 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

LINQ and XML for compact framework

Hi

I am currently building an application on .NetCF 3.5 in C#. The
application needs to process xml files. I am thinking about using LINQ
to process XML. I wrote a piece of code to modify the specified
element's value.
XmlReaderSettin gs settings = new
XmlReaderSettin gs();
settings.Confor manceLevel =
ConformanceLeve l.Fragment;
settings.Ignore Whitespace = true;
settings.Ignore Comments = true;
XmlReader reader = XmlReader.Creat e(inboxPath,
settings);

XElement root = XElement.Load(r eader);
IEnumerable<XEl ementmsgs = from el in
root.Descendant s("Message")
where el.Element("Mes sageID").Value ==
MsgID
select el;

foreach (XElement el in msgs)
{

el.Element("Mes sageStaus").Set Value(newStatus .ToString());
}
root.Save(inbox Path);

Here is the error message that I received :

msgs.System.Col lections.Generi c.IEnumerator<T Source>.Current 'System.Collect ions.Generic.IE numerable<Syste m.Xml.Linq.XEle ment>'
does not contain a definition for 'System' and no extension method
'System' accepting a first argument of type
'System.Collect ions.Generic.IE numerable<Syste m.Xml.Linq.XEle ment>'
could be found (are you missing a using directive or an assembly
reference?)

Could someone please explain to me why I get such error message? By
the way I have refference all the necessary dlls. (System.linq;
System.xml.linq )

Is it because I am using compact framework? I've tested this code on
a normal framework. It is working fine.

Jun 27 '08 #1
24 3816
<lu****@gmail.c omwrote:

<snip>
Is it because I am using compact framework? I've tested this code on
a normal framework. It is working fine.
That's very strange indeed - what line does the error message point at?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.co m>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #2
Wan
On Apr 30, 7:52*pm, Jon Skeet [C# MVP] <sk...@pobox.co mwrote:
*<luo...@gmail. comwrote:

<snip>
Is it because I am using compact framework? *I've tested this code on
a normal framework. *It is working fine.

That's very strange indeed - what line does the error message point at?

Could you post a short but complete program which demonstrates the
problem?

Seehttp://www.pobox.com/~skeet/csharp/complete.htmlfo r details of
what I mean by that.

--
Jon Skeet - <sk...@pobox.co m>
Web site:http://www.pobox.com/~skeet*
Blog:http://www.msmvps.com/jon.skeet
C# in Depth:http://csharpindepth.com
Actually it is not error, my program is still running. However, if I
place a break point at
IEnumerable<XEl ementmsgs = from el in
root.Descendant s("Message")
where el.Element("Mes sageID").Value ==
MsgID
select el;

After the statement is excuted, if I look up 'msgs' 's value, I will
get such error message.
Jun 27 '08 #3
Wan <lu****@gmail.c omwrote:
Actually it is not error, my program is still running. However, if I
place a break point at
IEnumerable<XEl ementmsgs = from el in
root.Descendant s("Message")
where el.Element("Mes sageID").Value ==
MsgID
select el;
After the statement is excuted, if I look up 'msgs' 's value, I will
get such error message.
In that case it sounds like a debugger problem rather than anything
else.

--
Jon Skeet - <sk***@pobox.co m>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #4
Wan
On Apr 30, 9:46*pm, Jon Skeet [C# MVP] <sk...@pobox.co mwrote:
Wan <luo...@gmail.c omwrote:
Actually it is not error, my program is still running. *However, if I
place a break point at
IEnumerable<XEl ementmsgs = from el in
root.Descendant s("Message")
* * * * * * * * * * * * * * * *where el.Element("Mes sageID").Value ==
MsgID
* * * * * * * * * * * * * * * *select el;
After the statement is excuted, if I look up 'msgs' 's value, I will
get such error message.

In that case it sounds like a debugger problem rather than anything
else.

--
Jon Skeet - <sk...@pobox.co m>
Web site:http://www.pobox.com/~skeet*
Blog:http://www.msmvps.com/jon.skeet
C# in Depth:http://csharpindepth.com
I've tested on two PCs, both the same.
Can some one post a tested working code of query the XML by using LINQ
with compact framework?
Jun 27 '08 #5
Wan <lu****@gmail.c omwrote:
I've tested on two PCs, both the same.
Can some one post a tested working code of query the XML by using LINQ
with compact framework?
Well hang on - you've posted an error which you look in the debugger.
You've said the program is still running. What's it doing that you
don't expect it to?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.co m>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #6
On May 1, 10:56 am, Wan <luo...@gmail.c omwrote:
Here is the full sample code. with the XML sample.
Well, it's not exactly a full sample - it doesn't contain a Main
method, for instance. It's not even a complete class - where's the
implementation of InitializeCompo nent?
Hint: console apps are generally a lot shorter.

See http://pobox.com/~skeet/csharp/incomplete.html
When I said the program was running, I mean the code was compiled.
However, the code does not do the job. The project I created was
based on Windows Mobile 6 SDK and Compact Framework 3.5.
When you say "the code does not do the job" what exactly do you mean?
What does it do, and what do you want it to do?

Jon
Jun 27 '08 #7
Wan
On May 1, 11:44*am, "Jon Skeet [C# MVP]" <sk...@pobox.co mwrote:
On May 1, 10:56 am, Wan <luo...@gmail.c omwrote:
Here is the full sample code. with the XML sample.

Well, it's not exactly a full sample - it doesn't contain a Main
method, for instance. It's not even a complete class - where's the
implementation of InitializeCompo nent?
Hint: console apps are generally a lot shorter.

Seehttp://pobox.com/~skeet/csharp/incomplete.html
When I said the program was running, I mean the code was compiled.
However, the code does not do the job. *The project I created was
based on Windows Mobile 6 SDK and Compact Framework 3.5.

When you say "the code does not do the job" what exactly do you mean?
What does it do, and what do you want it to do?

Jon
Hi Jon

I think it is complete, Please create a windows application project
with smart device. Put the code under Form.cs. I don't think you
need to implement a 'Main'.

Regards,
Wan
Jun 27 '08 #8
Wan
On May 1, 11:44*am, "Jon Skeet [C# MVP]" <sk...@pobox.co mwrote:
On May 1, 10:56 am, Wan <luo...@gmail.c omwrote:
Here is the full sample code. with the XML sample.

Well, it's not exactly a full sample - it doesn't contain a Main
method, for instance. It's not even a complete class - where's the
implementation of InitializeCompo nent?
Hint: console apps are generally a lot shorter.

Seehttp://pobox.com/~skeet/csharp/incomplete.html
When I said the program was running, I mean the code was compiled.
However, the code does not do the job. *The project I created was
based on Windows Mobile 6 SDK and Compact Framework 3.5.

When you say "the code does not do the job" what exactly do you mean?
What does it do, and what do you want it to do?

Jon
'InitializeComp onent' method is generated when the project is
created. Since VS 2005, it is seperated from the form class.

Regards,
Wan
Jun 27 '08 #9
On May 1, 12:43 pm, Wan <luo...@gmail.c omwrote:
I think it is complete,
No, it's definitely not.
Please create a windows application project
with smart device. Put the code under Form.cs. I don't think you
need to implement a 'Main'.
Only because Visual Studio creates another file for you that *does*
contain Main. Likewise the Form1.Designer. cs file contains
InitializeCompo nent. Without that, it's not complete.

In short, I can't cut and paste the code into a text editor *on its
own* and compile from the command line, which is what I tend to do
with newsgroup posts. Again, please read
http://pobox.com/~skeet/csharp/incomplete.html

You also *still* haven't said how it behaves differently to how you
expect it to.

Jon
Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4977
by: boble | last post by:
Sorry, it's may be off topic ;_((( The following article http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnppc2k3/ht ml/winmob03.asp states that a.. Microsoft Windows .NET Compact Framework-The .NET Compact Framework is in ROM in all new Pocket PC 2003 devices, and can be installed in RAM in Pocket PC 2000 and Pocket PC 2002 devices. The question is: how? Answers would be greatly appreciated
0
2605
by: Earle Oxner | last post by:
We are developing an application on PocketPC2002 platform and we are trying to make webservice calls using HTTPS. HTTP works fine but HTTPS does not work. The same code which doesn't work on PocketPC, works on the laptop with .NET Framework. I was hoping you could help me with answering some questions: 1. Does HTTPS work for the System.Net.WebRequest.Create (sURL), GetRequestStream, System.IO.StreamWriter library calls we are making...
2
2865
by: Duncan | last post by:
I am using the evaluation version of CE.NET 4.1. I had also installed the release version of the Compact Framework. I uninstalled the CE.NET 4.1, and then realized I needed it again and reinstalled it. I also installed all the QFEs. When I tried to reinstall the release Compact Framework, I get a message that it is already installed and the installation aborted.
1
2523
by: Asad Khan | last post by:
Hi, I have Visual Studio 2002 Enterprise Architecture Edition. I was wondering if anyone has any information on how I can develop applications for .Net Compact Framework using this IDE. I've heard Visual Studio 2003 ships with the functionality for .Net Compact Framework development. But right now I have Visual Studio 2002. Is there anything I can do? (Other than the obvious upgrade to 2003). I've heard some beta version of .Net Compact...
2
3585
by: paul | last post by:
I have developed an application for pocket pc that requires multiple forms to be open at any one time. The user is able to flick from one to the other, making changes to each as and when necessary The application uses a stacking system to hold instances of the forms, and an array to hold "previous navigation" information (information on this method was found on "http://smartdevices.microsoftdev.com/Learn/Articles/505.aspx") The problem I have...
4
2027
by: André Giesing | last post by:
Hello NG! I've got a short question: Is there a difference of the internal representation of a Hashtable between the Compact Framework and the normal Framework? I've got the suspicion, because when I Serialize the same Object (with a Hashtable in it) on a Computer with the normal .NET Framework and on a mobile Device (which uses the Compact Framework) the byteStream is different!
0
1549
by: Roland Rosier | last post by:
Hello, I am trying to understand Managed C++ and the .Net Framework, and as far as I can tell, you add a /CLR option to the compiler to make it generate MSIL from C++. However, I need to generate MSIL for use with the Compact Framework used on Windows CE and I cannot see any obvious way to make Visual Studio.Net C++ generate MSIL that uses the
5
4247
by: brett | last post by:
When I do Console.Write("something here") or WriteLine() on the Compact Framework, nothing appears in the output window. I have also tried it on another developer's machine with the same results. The Docs say this is supported in the Compact Framework. Any ideas? Thanks, Brett
3
2626
by: Greg | last post by:
Hello all, I am looking to download an image from a website from within a compact framework pda app. I have tried everything I could find and thus I turn to you. Any help or suggestions would be appreciated. Thank you.
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.