使用对dll的引用实例化.NET类会导致FileNotFoundException

时间:2013-09-19 10:42:38

标签: c# visual-studio dll pdfsharp pdfclown

我已经为项目添加了参考PDFSharp类。当我尝试在包含PDFSharp库的类中使用方法时,我得到一个FileNotFoundException,表示我缺少引用的(PDFSharp)文件(虽然我可以向你保证dll文件在那里)。

所以我尝试添加和读取并更改dll版本,但仍然没有成功。所以我切换到PDFClown,一个类似的目的库,但错误是相同的:FileNotFoundException在运行时。

甚至在执行方法之前抛出异常。

调用方法(抛出异常的地方):

//method call: here the debugger stops at the breakpoint
ReportUtils.CreateFile(tempDirectoryPath ecc);

叫方法:

using org.pdfclown.documents;
using org.pdfclown.documents.contents.composition;
using org.pdfclown.documents.contents.fonts;
using clownFiles = org.pdfclown.files;

class ReportUtils
{
    public static void CreateFile(/*parameters*/)
    {
             //the debugger never enter here: the exception is thrown before
             string filename = Settings.ReportFileName + String.Format("{0:yyyyMMddHHmmssffff}", DateTime.Now);
             //ecc
    }
//...

为什么会出现此异常?我在添加引用时做错了吗?

1 个答案:

答案 0 :(得分:1)

我可以通过将库中的选项Copy Local设置为false来重现您的问题。请确保此布尔值设置为true.

enter image description here