I vaguely recall a bug here that might have been in the CTP release.

I think you can work around it; I forget all the details, but you should check msbuild output to see both what foo.resources file (possible with foo=<empty>) is getting generated and what F# fsc.exe command-line is linking in that resources file. I think there is an fsc.exe command-line option to provide a logical name for the resource that is distinct from the physical filename getting wrongly generated by the msbuild and bad Microsoft.FSharp.targets logic (something like "--resource physicalname,logicalname"). Once you get the right name into the assembly (verify with Reflector), then you can use that name in the ResourceManager call. Hopefully that's enough info for you to work it out, please post here if you figure it out or still get stuck.

By on 3/23/2009 12:54 PM ()

Apparently, the --resource flag is to be used with .res files, the --linkresource file[, outputResourceFile[, public|private]] didn't work (that is, a file with the expected output file name appeared in reflector, but it was empty).

Using the "normal" compilation process, the resources were indeed in .resources (no name, just an extension) in the resources folder.

To access it, instead of using a namespace, I had to use

1
2
3
4
5
6
7
8
9
 

open System.Resources

let executingAssembly = System.Reflection.Assembly.GetExecutingAssembly()
let resources = new ResourceManager("", executingAssembly)
    
let crosshair : Bitmap = unbox <| resources.GetObject("crosshair")

If someone has a solution to put the resource output in a predetermined namespace, I'd be happy to hear it.

Incidentally, it seems that when trying to embed multiple culture files (form1.FR.resx, form2.FR.resx etc.), it can't merge them (while VC# does). Is there a way to circumvent this (to avoid overly mixing C# and F# ?)

Error message related to the "merger" of culture files :
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\AL.exe /culture:fr /out:obj\Debug\fr\Gui.resources.dll /template:obj\Debug\Gui.exe /embed:obj\Debug\.resources /embed:obj\Debug\.resources

ALINK(0,0): error AL1046: L'identificateur de ressource '.resources' a déjà été utilisé dans cet assembly

cheers

By on 3/23/2009 5:28 PM ()

Ok, I went combing through the bug database and this was indeed totally broken in the CTP (e.g. bugs 3112, 3585). We'll be in better shape in the next release.

I doubt you'll be able to get resource 'merging' working at all in the CTP; you seem to have a decent handle on the naming/namespace issues.

As you mention, using a C# project to 'get this bit right' may be the only workaround for now.

By on 3/23/2009 11:56 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper