dll - 如何在 F# 源文件 (fs) 中引用 system.drawing。它适用于脚本文件 (fsx)

标签 dll bitmap f# visual-studio-2015

我目前正在使用 Visual Studio 2015 在 F# 中编码

我正在尝试访问 .Net 命名空间 System.Drawing 来制作位图。我从学校获得了一个工作示例项目,它绘制一个位图并每秒更新一次。该文件是一个扩展名为.fsx的F#脚本文件

问题是我无法访问 System.Drawing 命名空间并使用相同的代码,如果我将它复制并粘贴到扩展名为 .fs 的 F# 源文件中。

Visual Studio 的智能甚至不显示 .Drawing 命名空间。

我试过谷歌搜索,但我不知道要搜索什么。

最佳答案

在 Visual Studio 中

从菜单:查看 -> 解决方案资源管理器

enter image description here

展开项目。在这个例子中是 ConsoleApplication2

enter image description here

右键单击引用

enter image description here

点击添加引用...

enter image description here

enter image description here

在左侧单击程序集
默认情况下应选择框架。如果不选择Framework

enter image description here

在右上角进行搜索。
输入搜索词时不要完成后按回车键。
要搜索,请输入:绘图

enter image description here

在中间
点击 System.Drawing

enter image description here

点击System.Drawing左边的框

enter image description here

点击确定

展开引用

enter image description here

验证已添加对 System.Drawing 的引用。

在顶部的 fs 文件中添加以下行

open System.Drawing

enter image description here

您现在可以使用库,例如

enter image description here

微软笔记

有关创建项目的完整示例,请参阅:

Walkthrough: Using Visual F# to Create, Debug, and Deploy an Application

关于添加引用的部分在

To develop a component by using F#

并且是第 3 项。

Open the shortcut menu on this project's References node, and then choose Add Reference. Choose the Solution node, and then choose the Projects node. Select the check box next to the RateAnalysis project, and then choose the OK button

.

关于dll - 如何在 F# 源文件 (fs) 中引用 system.drawing。它适用于脚本文件 (fsx),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35023269/

相关文章:

.net - Lazy.Force() 和 Lazy.Value 有什么区别

f# - 来自 F# 编译器的虚假 "Duplicate definition of value"错误

java - Android NDK 可以将 Windows dll 包含到 Android 共享库中吗?

c++ - 尝试为多种 BPP 格式创建保存位图功能

android - 从私有(private)存储android读取图像

Delphi - 将 bmp 转换为 png 失败

generics - F# 中算术转换为泛型类型

c++ - 如何在 DLL 中返回 vector ?

.net - 如何检查DLL文件针对的.NET Framework版本?

c++ - 在带有 Visual Studio 的 Windows 上使用 swig -go