C# 无法加载文件或程序集';itextsharp';或者它的一个依赖项
试着跟随RazorPDF的教程,我不知道为什么我会收到以下错误信息:非常沮丧和疲惫 错误消息: 无法加载文件或程序集“itextsharp”或其 依赖关系。定位程序集的清单定义不正确 匹配程序集引用。(来自HRESULT的异常:0x8013100) itextsharp: 运行时版本:v1.1.4322 版本:4.1.2.0 RazorPDF: 运行时版本:4.0.30319 控制器内部:C# 无法加载文件或程序集';itextsharp';或者它的一个依赖项,c#,asp.net-mvc,itextsharp,razorpdf,C#,Asp.net Mvc,Itextsharp,Razorpdf,试着跟随RazorPDF的教程,我不知道为什么我会收到以下错误信息:非常沮丧和疲惫 错误消息: 无法加载文件或程序集“itextsharp”或其 依赖关系。定位程序集的清单定义不正确 匹配程序集引用。(来自HRESULT的异常:0x8013100) itextsharp: 运行时版本:v1.1.4322 版本:4.1.2.0 RazorPDF: 运行时版本:4.0.30319 控制器内部: public ActionResult Index() { var stud
public ActionResult Index()
{
var studentMarks = new List<MarksCard>()
{
new MarksCard()
{
RollNo = 101, Subject = "C#",
FullMarks = 100, Obtained = 90},new MarksCard() {RollNo = 101, Subject = "asp.net", FullMarks = 100, Obtained = 80},new MarksCard() {RollNo = 101, Subject = "MVC", FullMarks = 100,
Obtained = 100},new MarksCard() {RollNo = 101, Subject = "SQL Server", FullMarks = 100, Obtained = 75},
};
//// return new RazorPDF.PdfResult(studentMarks, "Index");
return View(studentMarks);
}
public ActionResult Index()
{
var studentMarks=新列表()
{
新标记()
{
RollNo=101,Subject=“C#”,
满分=100,获得=90},新标记({RollNo=101,Subject=“asp.net”,满分=100,获得=80},新标记({RollNo=101,Subject=“MVC”,满分=100,
已获得=100},新的MarksCard(){RollNo=101,Subject=“SQL Server”,满分=100,已获得=75},
};
////返回新的razordf.PdfResult(学生分数,“索引”);
返回视图(学生分数);
}
内部视图
@model IEnumerable<TimberBeamCalculator.Models.MarksCard>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.RollNo)
</th>
<th>
@Html.DisplayNameFor(model => model.Subject)
</th>
<th>
@Html.DisplayNameFor(model => model.FullMarks)
</th>
<th>
@Html.DisplayNameFor(model => model.Obtained)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.RollNo)
</td>
<td>
@Html.DisplayFor(modelItem => item.Subject)
</td>
<td>
@Html.DisplayFor(modelItem => item.FullMarks)
</td>
<td>
@Html.DisplayFor(modelItem => item.Obtained)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}
</table>
@model IEnumerable
@{
ViewBag.Title=“Index”;
}
指数
@ActionLink(“新建”、“创建”)
@DisplayNameFor(model=>model.RollNo)
@DisplayNameFor(model=>model.Subject)
@DisplayNameFor(model=>model.FullMarks)
@DisplayNameFor(model=>model.govered)
@foreach(模型中的var项目){
@DisplayFor(modelItem=>item.RollNo)
@DisplayFor(modelItem=>item.Subject)
@DisplayFor(modelItem=>item.FullMarks)
@DisplayFor(modeleItem=>item.govered)
@ActionLink(“编辑”,“编辑”,新的{/*id=item.PrimaryKey*/})|
@ActionLink(“详细信息”,“详细信息”,新的{/*id=item.PrimaryKey*/})|
@ActionLink(“删除”,“删除”,新的{/*id=item.PrimaryKey*/})
}
- 从此处获取iTextSharp的最新LGPL副本:
- 从此处下载RazorPdf源代码:
p.S.
Razordf
使用iTextSharp的HTMLWorker
。它已被弃用,不再受支持。它的HTML到PDF功能非常有限。他们最近用XMLWorker
替换了它:检查以确保您确实将iTextSharp放在了正确的位置。我猜你错过了什么
我强烈建议您从最初的项目样本开始,并尝试让它们首先工作
- (2分钟的视频,向您展示如何使其工作。)
addreference
中删除dll
dll
的新副本dll
的引用这应该可以解决问题。我对itextsharp和itextsharp.xmlworker DLL有问题,因此我从参考中删除了这两个DLL,并直接从nuget软件包下载了新的DLL,从而解决了我的问题
此方法可能有助于向其他人解决问题。您是否检查了当前.net版本支持的itextsharp.dll和razor版本?这可能是您感兴趣的,谢谢您的回复。我能够从Github获得您的示例项目,并在我的机器上成功运行。您的项目以.net 4.0为目标,而我的项目以.net 4.5为目标。。我不知道这是否有区别。艾尔,谢谢你的演示。。我从没有那些DLL的地方重新启动了代码库,从头开始注册DLL。。。我不确定问题出在哪里,我通过NuGet将iTextSharp从5.5.8版升级到5.5.9版,收到了错误。我把它从我的引用列表中删除,然后把它重新添加到dll中,它就工作了。不一定,当它发生在我身上时,我没有调试。我通常使用CTRL+F5测试我的站点,因为我不喜欢停止运行站点来更新代码和测试更改。我只在需要通过断点运行时在调试中运行它。