【问题标题】:You must add a reference to assembly 'System, Version=1.0.5000.0您必须添加对程序集 'System, Version=1.0.5000.0 的引用
【发布时间】:2012-03-31 13:23:33
【问题描述】:

我正在尝试在我的 Windows Mobile 的 C# 程序中包含一个 html 到 pdf 转换器。 我找到了 Pdfizer。 我添加了对 Pdfizer.dll 的引用并将其包含在 using Pdfizer; 中 我还添加了对 Pdfizer 所需的 itextsharp 的引用。

Pdfizer 已正确添加,我可以使用它的许多函数和类,但我不能使用 HtmlToPdfConverter.Run()

我的代码:

FileStream filePDF;
filePDF = File.Create(path + ".pdf"); // path is string
html2pdf.Open(filePDF);
html2pdf.AddChapter(@"Chapter name");
html2pdf.Run(html); // html is a string that contains html code
html2pdf.Close();

问题就在html2pdf.Run(html); 一行,上面写着:

Error   1   The type 'System.Uri' is defined in an assembly that is not referenced.
You must add a reference to assembly 'System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.    

Run的定义是

    public void Run(string html);
    public void Run(Uri uri);

我正在尝试使用 Run(string html) 选项,但 Uri 已定义,Visual Studio 说它没有被引用,但是是的。

我有 using System; 包含 Uri 类,确实我在其他功能中使用它并且工作正常。

有什么问题?我应该添加对System, Version=1.0.5000.0 的引用吗?我在哪里可以找到它?有没有办法告诉 Pdfizer Uri 在 System.Uri 中?

谢谢

【问题讨论】:

    标签: c# visual-studio-2008 windows-mobile pdf-generation itextsharp


    【解决方案1】:

    b77a5c561934e089 的公钥标记表示您正在引用桌面程序集,所以我敢打赌 Pdfizer 仅适用于桌面。没有办法在 COmpact 框架中进行这项工作。如果你能得到源代码,你可以尝试为CF编译它,否则你将不得不询问所有者他们是否有CF版本。

    【讨论】:

    • 我在尝试使用 RestSharp 时遇到了类似的情况。这段代码: RestRequest request = new RestRequest("api/departments/", Method.GET);引发编译时错误:“类型'System.Uri'在未引用的程序集中定义。您必须添加对程序集'System,Version = 2.0.0.0,Culture = Neutral,PublicKeyToken = b77a5c561934e089'的引用”我在其他地方读到过 RestSharp 可以从 Windows CE 客户端使用,所以我陷入了僵局......
    • 我引用的系统程序集位于 C:\Program Files (x86)\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\System.dll 中。运行时版本 == v2.0.50727,版本 == 3.5.0.0
    • 所有 程序集必须引用 CF。所有第三方程序集、DLL 等也必须是参考 CF 构建的。
    • 所以现在我想知道 RestSharp 是否真的是从我的 CE 应用程序访问 WebAPI 方法的可行选择; HttpClient 直到 .NET 4.5 才可用,所以我现在介于石化的土块和不屈的地方之间......
    • 是的,您只需要 CF 编译的 RestSharp 程序集。我知道它存在,因为我自己建造了一个。
    猜你喜欢
    • 2018-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-24
    • 2022-09-29
    • 2019-10-16
    • 1970-01-01
    • 2019-11-26
    相关资源
    最近更新 更多