简体   繁体   English

缺少编译器所需的成员“microsoft.csharp.runtimebinder.binder.convert”

[英]Missing compiler required member 'microsoft.csharp.runtimebinder.binder.convert'

I first time using Excel to reading data in c# with Selenium WebDriver, but when I build this code, it pops up an error:我第一次使用 Excel 用 Selenium WebDriver 读取 c# 中的数据,但是当我构建这段代码时,它弹出一个错误:

"Missing compiler required member 'microsoft.csharp.runtimebinder.binder.convert'" “缺少编译器所需的成员‘microsoft.csharp.runtimebinder.binder.convert’”

and the code for using excel is marked in red bellow:使用excel的代码如下红色标注:

 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. Office 的引用程序集通过dynamic返回类型公开。 To be able to compile you need to add a reference to Microsoft.CSharp.dll .为了能够编译,您需要添加对Microsoft.CSharp.dll的引用。

In addition to what @Alex Ghiondea says, go to the references section of your project:除了@Alex Ghiondea 所说的,请转到您项目的参考部分:

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.单击添加引用,将出现带有左侧菜单(程序集、项目、COM 和浏览)的模式。
  2. Click Assemblies单击组件
  3. Check Microsoft.CSharp and click Ok.检查 Microsoft.CSharp 并单击确定。
  4. Clean and build your project and the error should disappear.清理并构建您的项目,错误应该会消失。

在此处输入图片说明

如果您的项目面向 .Net Core 或 .Net Standard,则安装Microsoft.CSharp NuGet 包将解决此错误。

Add a reference of Microsoft.CSharp to your project by using NuGet.使用 NuGet 将 Microsoft.CSharp 的引用添加到您的项目中。

在此处输入图片说明

or

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

I'm using Visual Studio 2017 Version 15.7.1 (not sure if this matters or not, but this error seems to have cropped up after I updated).我正在使用 Visual Studio 2017 版本 15.7.1(不确定这是否重要,但在我更新后似乎出现了此错误)。 I had a project that was targeting .NET Framework 3.5.我有一个针对 .NET Framework 3.5 的项目。 So, in addition to the other answers provided for adding Microsoft.CSharp, I needed to update this project to .NET Framework 4.5, and then Microsoft.CSharp showed up under Assemblies when I went to add the reference.因此,除了为添加 Microsoft.CSharp 提供的其他答案外,我还需要将此项目更新到 .NET Framework 4.5,然后当我添加引用时,Microsoft.CSharp 出现在程序集下。 Before then, I had to find the absolute path to the DLL, which didn't seem to work.在此之前,我不得不找到DLL的绝对路径,这似乎不起作用。

For those who can't upgrade to 4.5, you can try setting EmbedInteropTypes to False for all interop references in your csproj file, as shown here: http://answers.flyppdevportal.com/MVC/Post/Thread/b1554cdd-ad9e-4453-b4d6-8eb03da175ea?category=visualstudiogeneral对于无法升级到 4.5 的用户,您可以尝试将 csproj 文件中所有互操作引用的 EmbedInteropTypes 设置为 False,如下所示: http ://answers.flyppdevportal.com/MVC/Post/Thread/b1554cdd-ad9e- 4453-b4d6-8eb03da175ea?category=visualstudiogeneral

right click on project name (in solution explorer), Add refrence : Microsoft.CSharp in the assemblies , then right click again and Clean .右键单击项目名称(在解决方案资源管理器中),在程序集中添加引用:Microsoft.CSharp,然后再次右键单击并清理 that's all.仅此而已。

I had this problem as well.我也有这个问题。 If you right click and select Properties (While project is highlighted), there is a checkbox that says: Auto-generate binding redirects.如果您右键单击并选择“属性”(突出显示项目时),则会有一个复选框显示:自动生成绑定重定向。 This fixed it for me.这为我修好了。

I am using Visual Studio 2017 and it is a C# class library.我使用的是 Visual Studio 2017,它是一个 C# 类库。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 C# 中嵌入 IronPython 的问题(缺少编译器所需的成员“Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember” - Problems embedding IronPython in C# (Missing Compiler required member 'Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember' 如何修复“错误 CS0656:缺少编译器所需的成员‘Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create’” - How to fix "error CS0656: Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'" 缺少类型Microsoft.CSharp.RuntimeBinder.Binder - Missing type Microsoft.CSharp.RuntimeBinder.Binder ASP.NET Core 1.1 使用 C# 动态编译 缺少编译器需要成员 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create' - ASP.NET Core 1.1 compiling with C# dynamic Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create' 缺少编译器所需的成员,但已添加 Microsoft.CSharp package - Missing compiler required member but have already added Microsoft.CSharp package 立即窗口中的动态导致'Microsoft.CSharp.RuntimeBinder.Binder'未定义或导入错误 - Dynamic in the immediate window causes 'Microsoft.CSharp.RuntimeBinder.Binder' is not defined or imported error Microsoft.CSharp.RuntimeBinder.RuntimeBinderException错误 - Microsoft.CSharp.RuntimeBinder.RuntimeBinderException Error 发生``Microsoft.CSharp.RuntimeBinder.RuntimeBinderException'' - 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred 为什么Microsoft.CSharp.RuntimeBinder.RuntimeBinderException如果有调用的方法? - Why a Microsoft.CSharp.RuntimeBinder.RuntimeBinderException if the invoked method is there? 未定义或导入预定义类型microsoft.csharp.runtimebinder - Predefined type microsoft.csharp.runtimebinder is not defined or imported
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM