c# - 不能使用 FileFormatException (?)

标签 c# exception xna

我目前正在为我的小型 XNA 项目编写一个自定义导入程序,并试图做一些像抛出 FileFormatException 这样简单的事情。在我的导入器 Import 方法中。

我已经引用了 WindowsBase.dll,所以 FileFormatException 应该在 IntelliSense 的 System.IO 下可用,对吗?我键入 System.IO 并且 System.IO 下没有自动完成 FileFormatException

这里是抛出语句所在的地方:

namespace TetrominoImporter
{
    public class TetrominoReader : ContentImporter<Tetromino>
    {
        public const string blockFileName = "blocks.txt";

        public override Tetromino Import(string filename, ContentImporterContext context)
        {
            // HERE

最佳答案

您需要在引用中包含 WindowsBase,因为 FileFormatException 是在该程序集中定义的。一旦你添加了它,你应该能够解决 System.IO.FileFormatException

关于c# - 不能使用 FileFormatException (?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15534149/

相关文章:

c# - 使用 sql 查询结果填充 datagridview

c# - 有没有办法在 C# 中的 2 个 IEnumerable 中对每个元素对执行 foreach?

node.js - Visual Studio 2017 Node.js 异常不起作用

使用调用跟踪的 C++ 异常处理

c# - 关于 MathHelper.ToRadians(); 的问题

c# - 编写 .x 文件

c# - C# XNA 与 Farseer Physics 中的 OnCollision 事件处理程序问题

c# - 在集合对象上实现 IXmlSerializable

c# - 当用户双击其关联文件时,如何打开应用程序?

spring-boot - 使用外部 jar 中的 ControllerAdvice