0
votes

I'm trying to read in the text (as a string) of an XML file from my Resources. The XML file is named MyXMLResourceFile.resx.

I tried using the C# way using

let myFile : string = Properties.Resources.MyXMLResourceFile

but it is giving me the error (under Properties):

The namespace or module 'Properties' is not defined.

I'm assuming I'm missing an open but have no idea what it would be.

Sorry, I'm still pretty new to F# coming from VB.

Additional information:

I made the resx file myself per this SO answer I then looked to see how others accessed it. In C# they did Properties.Resources.XXXX per this project I saw you could use ResourceManager but didn't see any method to read the whole file directly into a string.

1
Could you please clarify what kind of application are you creating (ASP.NET, WPF, or something else?) and how did you create it (using some template?)Tomas Petricek
I'm creating a library. I'm not using a template.Jon49

1 Answers

1
votes
The namespace or module 'Properties' is not defined.

That's because the namespace Properties is not defined. You probably brought the resx file from another project. Open the associated .Designer file, if it doesn't appear in the F# project, open it up in the original project. You will see a namespace with and a bunch of C# code, assuming the original project was in C#. The namespace of this file has to be the same namespace of the project where you are trying to call it.

But, since this is C# code, it won't run on a F# project. You have two choices: use a code generator to generate the associated .Designer class in F# code with the Properties namespace, (I don't know if such generator exists); or pre-compile the resx in the original project and reference it as a dll from your F# project, then you can access it with ResourceManager.