Logo




Subscribe:
RSS 2.0 | Atom 1.0
Categories:

Sign In


[Giagnocavo]Michael::Write()

# Tuesday, October 28, 2008
F# 1.9.6.2 and Silverlight 2
Compiling for Silverlight 2 is a bit of a pain still. It's even worse with F#, because the Silverlight project system cannot tell when you're building your F# components correctly (using the right flags). So you get this error:

---------------------------
Microsoft Visual Studio
---------------------------
You can only add project references to other Silverlight projects in the solution.
---------------------------
OK  
---------------------------

This happens even if you set up the F# compiler options correctly by adding:
--standalone --noframework --cliroot "C:\program Files\Microsoft Silverlight\2.0.31005.0"

It still happens if you reference the DLL directly (FSLib1\bin\debug), you get the same error! Apparently VS or Silverlight projects go and try to find the project relating to the DLLs when you add a reference. So, the solution is easy: Move the DLL somewhere else. Then you can add a file reference, and it will work just fine.

One more problem. I get an FSC error when I turn optimize code on:
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 leave optimize code off, then it seems to work. Good luck.

http://stackoverflow.com/questions/237044/how-does-silverlight-determine-an-assembly-is-silverlight


FSharp
Tuesday, October 28, 2008 10:27:50 PM UTC  #    Comments [5]  |  Trackback

Thursday, December 18, 2008 10:36:43 AM UTC
Hi! I've tried your method by moving the compiled dll into another folder in the post-build event.

However, when I try to add the reference from the silverlight project to the F# compiled project, it gives a error message about
You can't add reference to xxx.dll as it was not built against the Silverlight runtime.

Have any clues about this problem?

Thank you!

Tim
Thursday, December 18, 2008 10:07:50 PM UTC
Here is the compiler output:

C:\Program Files\FSharp-1.9.6.2\\bin\fsc.exe -o obj\Debug\Andrew.dll -g --noframework --platform x86 -r "C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" -r C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll --target library --warn 3 --warnaserror 76 --vserrors --fullpaths Andrew.fs

Thanks for your help!

Tim
Friday, December 19, 2008 7:34:57 AM UTC
You're referencing the desktop framework; that's why it's accurately saying that. I also don't see the --cliroot option. Finally, you probably want to consider using standalone to statically link it instead of distributing the entire FSharp libraries in the XAP.

The Silverlight DLLs are in C:\Program Files\Microsoft Silverlight\2.0.31005.0\.
Friday, December 19, 2008 9:49:52 AM UTC
Hi Miachel!

Here is the latest compiler output :

C:\Program Files\FSharp-1.9.6.2\\bin\fsc.exe -o obj\Debug\Andrew.dll -g --noframework --platform x86 -r C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll --target library --warn 3 --warnaserror 76 --vserrors --fullpaths --standalone --cliroot "C:\program Files\Microsoft Silverlight\2.0.31005.0" Andrew.fs


Right now when I launch visual studio I'm keep getting errors about Failing to load pre-requisites.

Once I remove the reference from the F# dll, it's working again.

Any clues? Can you maybe sure your compiler arguments so I can take a look ?

Thank you!

Tim
Friday, December 19, 2008 9:50:56 AM UTC
Forgot to tell you, by adding the cliroot and standalone makes teh solution build. :)

Please let me know if you can help me with the latest problem.

Thank you!
OpenID
Please login with either your OpenID above, or your details below.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Live Comment Preview