2012-03-10 50 views
12

Lỗi:Không thể tải tập tin hoặc lắp ráp ICSharpCode.SharpZipLib ... Khi sử dụng NuGet gói ExcelDataReader

Could not load file or assembly 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73' or one of its dependencies. The system cannot find the file specified.`

Stack:

[FileNotFoundException: Could not load file or assembly 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73' or one of its dependencies. The system cannot find the file specified.]
Excel.Core.ZipWorker.Extract(Stream fileStream) +0
Excel.ExcelOpenXmlReader.Initialize(Stream fileStream) +78

[Asp.Net MVC3 C#]

Sử dụng Gói NuDet ExcelDataReader Tôi đã cố gắng mở một tệp .xlsx đã lưu trên hệ thống tệp. Dưới đây là các mã được sử dụng:

string filePath = HttpContext.Server.MapPath("~/blank3.xlsx"); 
FileStream stream = System.IO.File.Open(filePath, FileMode.Open, FileAccess.Read); 
IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream); 

đây là trang web cho gói NuGet: http://exceldatareader.codeplex.com/

gì cho? Điều này sẽ làm việc mà không có một xô.

Trả lời

12

Tôi đã gặp phải vấn đề tương tự; để giải quyết, tôi đã tìm thấy hội đồng tên mạnh phù hợp trong dự án mã vạch của họ.

Đã tải xuống mã nguồn từ http://exceldatareader.codeplex.com, đã lấy cụm từ thư mục LIB của họ và tham chiếu nó từ dự án của tôi.

+2

Bạn có thể rõ ràng hơn một chút về quy trình của mình không? –

0

ICSharpCode.SharpZipLib là tập hợp tên mạnh. Số phiên bản hội phải khớp chính xác hoặc không tải được. Vui lòng kiểm tra phiên bản lắp ráp.

+1

Tôi sẽ tìm thấy hội đồng ở đâu? Nó không được bao gồm như bất kỳ gói nào hoặc trong tệp web.config của tôi. –

0

vì dll là .net phiên bản 2.0, dự án của bạn là cao hơn, nếu bạn cài đặt các gói từ quản lý gói NuGet, nó sẽ lắp ráp ô tô sử dụng thời gian chạy ràng buộc, file web.config/app.config nên như thế này :

<runtime> 
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
    <dependentAssembly> 
    <assemblyIdentity name="ICSharpCode.SharpZipLib" publicKeyToken="1b03e6acf1164f73" culture="neutral" /> 
    <bindingRedirect oldVersion="0.0.0.0-0.85.4.369" newVersion="0.85.4.369" /> 
    </dependentAssembly> 
</assemblyBinding> 

1

Nếu những gì bạn đang nhận được là:

Could not load file or assembly 'ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73' or one of its dependencies. The system cannot find the file specified.

Sau đó, giải pháp là để tải về latest (hoặc chọn đúng version cho lỗi của bạn) ICSharpCode.SharpZipLib.dll từ SharpZipLib website và chỉ cần đặt nó vào thư mục nơi đặt của ExcelDataReader là Excel.dll (không cần tham khảo).

Các vấn đề liên quan