Lỗi could not load file or assembly office năm 2024

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900

Sau khi cài đặt thành công phần mềm DỰ TOÁN BNSC 2O2O, một số máy gặp tình trạng xuất hiện “Lỗi khởi tạo chương trình: Could not load file or assembly..., Versions 15.0.. …” khi khởi động phần mềm (Như hình H.1 hoặc H.2)

Lỗi could not load file or assembly office năm 2024

H.1- Thông báo Dự toán BNSC

Lỗi could not load file or assembly office năm 2024

H.2- Thông báo Dự toán BNSC

Nguyên nhân: Trường hợp này thường gặp ở các máy dùng Microsoft Office phiên bản 2010 và có GAC_MSIL chưa phù hợp.

Bạn tiến hành sửa lỗi theo các bước sau:

- Đầu tiên Bạn truy cập và tải file Fix_2020.zip về máy [Tại đây]

- Sau đó Bạn tiến hành giải nén file Fix_2020.zip > Được thư mục Fix_2020 chứa file 1 và thư mục GAC_MSIL (như hình H.3)

Lỗi could not load file or assembly office năm 2024

H.3- Thư mục Fix_2020

- Tiếp theo bạn thực hiện 2 thao tác sau để fix lỗi:

  1. Chạy file 1.reg Chép folder GAC_MSIL vào thay thế folder GAC_MSIL mặc định trên máy tại đường dẫn: C:\Windows\assembly

This blog article shows you how to write data to Excel. Refer to Write value to Excel spreadsheet using Microsoft.Office.Interop.Excel for .NET 5 and above you will get the following error:

‘Could not load file or assembly ‘office, Version=15.0.0.0, Culture=neutral

Lỗi could not load file or assembly office năm 2024

For .NET 5 and above, I have to use the NuGet package DotNetCore.NPOI. The code below achieve the same result as in the article Write value to Excel spreadsheet.

static void WriteExcel(String strFileName)

{

using (var fs = new FileStream(strFileName, FileMode.Create, FileAccess.Write))

{

IWorkbook workbook = new XSSFWorkbook();

ISheet sheet1 = workbook.CreateSheet(“Sheet1”);

int rowIndex = 4;

IRow row = sheet1.CreateRow(rowIndex);

row.CreateCell(4).SetCellValue(“6”);

sheet1.AutoSizeColumn(0);

rowIndex++;

workbook.Write(fs);

}

}

Should Microsoft makes the Microsoft.Office.Interop.Excel work for .NET 5 and above? I believe they should.

Source code download: https://github.com/chanmmn/msoffice/tree/master/ConAppCoreExcel/?WT.mc_id=DP-MVP-36769

Reference: https://github.com/dotnetcore/NPOI

About chanmingman

Since March 2011 Microsoft Live Spaces migrated to Wordpress (http://www.pcworld.com/article/206455/Microsoft_Live_Spaces_Moves_to_WordPress_An_FAQ.html) till now, I have is over 1 million viewers. This blog is about more than 50% telling you how to resolve error messages, especial for Microsoft products. The blog also has a lot of guidance teaching you how to get stated certain Microsoft technologies. The blog also uses as a help to keep my memory. The blog is never meant to give people consulting services or silver bullet solutions. It is a contribution to the community. Thanks for your support over the years. Ming Man is Microsoft MVP since year 2006. He is a software development manager for a multinational company. With 25 years of experience in the IT field, he has developed system using Clipper, COBOL, VB5, VB6, VB.NET, Java and C #. He has been using Visual Studio (.NET) since the Beta back in year 2000. He and the team have developed many projects using .NET platform such as SCM, and HR based applications. He is familiar with the N-Tier design of business application and is also an expert with database experience in MS SQL, Oracle and AS 400.