I\'m trying to compile code from F# to use in Silverlight. I compile with:
--noframework --cliroot \"C:\\program Files\\Microsoft Silverlight\\2.0.31005.0\" --standalon
Visual Studio uses the IsSilverlightAssembly() function in the Microsoft.VisualStudio.Silverlight.SLUtil type to check if a reference can be set.
David Betz has a nice blog post describing the details here.
Answer!
Apparently the problem is that when you add a reference to the bin\Release or bin\Debug, Visual Studio (or the Silverlight project system) decides to try to reference the project. This fails for whatever reason.
If you copy the F# output DLL to another location, then the reference goes through just fine. (This will be a file reference, not a project reference, of course.)
Then setup dependencies so the F# library builds first, then you can use a file reference to get the F#-generated binary.
Update: One more apparent issue. If I turn optimize code on, then I get this error:
C:\test\SilverlightApplication1\FSC(0,0): error FS0193: internal error: the module/namespace 'System' from compilation unit 'mscorlib' did not contain the namespace, module or type 'MarshalByRefObject'
If I keep optimized code off, this goes away and everything works fine.