Intermittently when compiling my project (it is a Console Application implementing a Windows Service) the above warning is posted.

(here full warning text)

Warning 1   Assembly 'SMDiagnostics' was referenced transitively and the assembly could not be resolved automatically. 
Static linking will assume this DLL has no dependencies on the F# library or other statically linked DLLs. Consider adding an explicit reference to this DLL.   
FSC 1   1   myService (Applications\myService\myService)

What does this error mean and what could be causing it?

2

There are 2 answers

2
Brian On BEST ANSWER

I am not 100% sure, here is my guess.

You are using System.ServiceModel, and have it added as a reference in your project. ServiceModel, in turn, uses the SMDiagnostics assembly, but you don't have that explicitly referenced in your project. You're maybe compiling with --standalone, and so it's warning you about not being able to find the transitive closure of all the assemblies?

Anyway, I expect that if you add an explicit reference to SMDiagnostics, the warning will go away. It's probably a harmless warning anyway (I think SMDiagnostics is probably in the GAC so it will be found at runtime regardless).

0
Joe Ellsworth On

Setting the --lib suppresses the FS2011 warning. It effectively tells fsc.exe where to search for the two DLL files so it can link them in at build time. We like the static build option because it enables our goal of being able to unzip our software to a new windows box and have it run with no other configuration required.

set FSLIB=--lib:c:\Windows\Microsoft.NET\Framework\v4.0.30319

set compileFlags=--debug:full --standalone --optimize+ --crossoptimize+ --tailcalls+ %FSLIB%

fsc %compileFlags% MyFSharpProgram.fsx

In lieu of the environment variables you can simply add the following to your compile command. --lib:c:\Windows\Microsoft.NET\Framework\v4.0.30319

You will need to substitute the whatever directory contains the necessary DLL for the one we used. I used the cygwin find command ran as administrator to find locate the directory.

find . | grep SMDiagnostics

Resolved the following warnings from F# (FSC.EXE) compiler

warning FS2011: Assembly 'System.ServiceModel.Internals' was referenced transitively and the assembly could not be resolved automatically. Static linking will assume this DLL has no dependencies on the F# library or other statically linkedDLLs. Consider adding an explicit reference to this DLL.

warning FS2011: Assembly 'SMDiagnostics' was referenced transitively and the assembly could not be resolved automatically. Static linking will assume this DLL has no dependencies on the F# library or other statically linked DLLs. Consider adding an explicit reference to this DLL.

Joe E