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!
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
.
In addition to what @Alex Ghiondea says, go to the references section of your project:
Right click on references and check the prompted options.
If your project is targeting .Net Core or .Net Standard, then installing the Microsoft.CSharp NuGet package will solve this error.
Add a reference of Microsoft.CSharp to your project by using NuGet.
Install-Package Microsoft.CSharp -Version 4.7.0
for the project
right click on project name (in solution explorer), Add refrence : Microsoft.CSharp in the assemblies , then right click again and Clean. that's all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With