Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing compiler required member 'microsoft.csharp.runtimebinder.binder.convert'

Tags:

c#

excel

I first time using Excel to reading data in c# with Selenium WebDriver, but when I build this code, it pops up an error:

"Missing compiler required member 'microsoft.csharp.runtimebinder.binder.convert'"

and the code for using excel is marked in red bellow:

 excel.Application x1Appl = new excel.Application();
 excel.Workbook x1WorkBook = x1Appl.Workbooks.Open(@"C:\app\o\SearchBy.xlsx");

 excel._Worksheet x1WorkSheet = x1WorkBook.Sheets[1];

Please let me know what is missing? Thank you!

like image 746
Excellent Avatar asked Apr 03 '18 19:04

Excellent


5 Answers

The reference assemblies for Office are exposed via the dynamic return type. To be able to compile you need to add a reference to Microsoft.CSharp.dll.

like image 148
Alex Ghiondea - MSFT Avatar answered Oct 18 '22 18:10

Alex Ghiondea - MSFT


In addition to what @Alex Ghiondea says, go to the references section of your project:

Right click on references and check the prompted options.

  1. Click on add reference and a modal with the left menu (assemblies, projects, COM and browse) will appear.
  2. Click Assemblies
  3. Check Microsoft.CSharp and click Ok.
  4. Clean and build your project and the error should disappear.

enter image description here

like image 76
eduardo92 Avatar answered Oct 18 '22 20:10

eduardo92


If your project is targeting .Net Core or .Net Standard, then installing the Microsoft.CSharp NuGet package will solve this error.

like image 53
Kolappan N Avatar answered Oct 18 '22 19:10

Kolappan N


Add a reference of Microsoft.CSharp to your project by using NuGet.

enter image description here

or

Install-Package Microsoft.CSharp -Version 4.7.0 for the project

like image 25
Karthikeyan VK Avatar answered Oct 18 '22 19:10

Karthikeyan VK


right click on project name (in solution explorer), Add refrence : Microsoft.CSharp in the assemblies , then right click again and Clean. that's all.

like image 9
Sharif Lotfi Avatar answered Oct 18 '22 20:10

Sharif Lotfi