FSC 编译警告:程序集“SMDiagnostics”被传递引用并且程序集无法自动解析

发布于 2024-12-02 18:23:10 字数 473 浏览 3 评论 0原文

在编译我的项目(它是一个实现 Windows 服务的控制台应用程序)时,会间歇性地发布上述警告。

(此处为完整警告文本)

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)

此错误是什么意思以及可能导致该错误的原因是什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梓梦 2024-12-09 18:23:10

我不是100%确定,这是我的猜测。

您正在使用 System.ServiceModel,并将其添加为项目中的引用。 ServiceModel 反过来使用 SMDiagnostics 程序集,但您没有在项目中明确引用它。您可能正在使用 --standalone 进行编译,因此它警告您无法找到所有程序集的传递闭包?

无论如何,我希望如果您添加对 SMDiagnostics 的显式引用,警告就会消失。无论如何,这可能是一个无害的警告(我认为 SMDiagnostics 可能位于 GAC 中,因此无论如何都会在运行时找到它)。

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).

青巷忧颜 2024-12-09 18:23:10

设置 --lib 会抑制 FS2011 警告。它有效地告诉 fsc.exe 在哪里搜索这两个 DLL 文件,以便它可以在构建时链接它们。我们喜欢静态构建选项,因为它使我们能够将软件解压缩到新的 Windows 盒子并使其无需其他配置即可运行。

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

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

fsc %compileFlags% MyFSharpProgram.fsx

您可以简单地将以下内容添加到编译命令中来代替环境变量。 --lib:c:\Windows\Microsoft.NET\Framework\v4.0.30319

您需要将包含必要 DLL 的目录替换为我们使用的目录。我使用以管理员身份运行的 cygwin find 命令来查找目录。

找到 . | grep SMD诊断

解决了 F# (FSC.EXE) 编译器中的以下警告


警告 FS2011:程序集“System.ServiceModel.Internals”被传递引用,并且无法自动解析程序集。静态链接将假定此 DLL 不依赖于 F# 库或其他静态链接的 DLL。考虑添加对此 DLL 的显式引用。

警告 FS2011:程序集“SMDiagnostics”被传递引用,并且无法自动解析程序集。静态链接将假定此 DLL 不依赖于 F# 库或其他静态链接的 DLL。考虑添加对此 DLL 的显式引用。

乔 E

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文