Using Xml Type Provider

31 views
Skip to first unread message

Thomas Clarke

unread,
Sep 20, 2015, 7:08:43 PM9/20/15
to F# Discussions
I'm having some newbie trouble using System.Data.XmlProvider

Specifically, I can create an XmlProvider type, but can't access its nodes XmlNodeType because I don't have a reference to the containing assembly.

The type is defined in System.Xml.Linq according to:


I can't find this with NuGet.

I'm using:

Microsoft Visual Studio Community 2015
Version 14.0.23107.0 D14REL
Microsoft .NET Framework
Version 4.6.00081

Installed Version: Community

Visual F# 2015 RC   00322-20000-00000-AA183
Microsoft Visual F# 2015 RC

NuGet Package Manager   3.0.0

This is probably something silly, can anyone help?

Best wishes, Tom


Tomas Petricek (Info)

unread,
Sep 20, 2015, 8:54:45 PM9/20/15
to fsharp-o...@googlegroups.com

If you’re working inside a project then System.Xml.Linq should be among the system libraries in the “Add Reference” dialog.

In a script file, you can just use #r "System.Xml.Linq.dll" and the system will find the library automatically for you.

 

(i.e. it is not a NuGet package – it’s a system library that comes with .NET)

 

Tomas

--
--
To post, send email to fsharp-o...@googlegroups.com
To unsubscribe, send email to
fsharp-opensou...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/fsharp-opensource
---
You received this message because you are subscribed to the Google Groups "F# Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fsharp-opensou...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thomas Clarke

unread,
Sep 21, 2015, 3:22:24 AM9/21/15
to F# Discussions
Thanks.

I have System.Xml.Linq as a reference in my project:

Assembly System.Xml.Linq
    Member of .NET Framework 4
    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.Linq.dll


It seems all is OK except VS2015 code completion does not work on XElement, and I get a note saying that I need a reference to it - which is wrong because I do have the reference.

However the code builds fine, and I can use XElement methods and properties.

So this is not a big problem. I only found it because I was using VS2015 code completion to explore a constructed object returned by the type provider.

I'm in the "writing core code is very quick but anything with .NET gets weird" stage of learning FSharp. Made worse than usual because I'm a newbie to .Net and the VS ecosystem.

Best wishes, Tom

Isaac Abraham

unread,
Sep 21, 2015, 5:42:31 AM9/21/15
to fsharp-o...@googlegroups.com
Hi Thomas

Are you writing that code in an .fsx script though? As Tomas alluded to, with scripts you need to #r any assemblies within a script - it doesn't get those from the project references.

From: Thomas Clarke
Sent: ‎21/‎09/‎2015 08:22
To: F# Discussions
Subject: Re: Using Xml Type Provider

Thomas Clarke

unread,
Sep 22, 2015, 8:32:20 AM9/22/15
to F# Discussions
No, all is now good, I'm using VS2015 to generate a command line executable.

My learning curve for FSharp is a bit different from many people's because I've not used VS or  .NET seriously before.

I appreciate very much the as-you-type type checking and auto-completion. Especially when learning the language I rely on it - quicker than looking up operators etc.

I'm still struggling to optimise my programming style in FSharp - but that is a topic for another thread.

Tom
Reply all
Reply to author
Forward
0 new messages