首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >System.IO.FileLoadException:

System.IO.FileLoadException:
EN

Stack Overflow用户
提问于 2020-05-30 12:23:18
回答 2查看 184关注 0票数 1

这是我使用的代码段,注意*是我名字的替换

代码语言:javascript
复制
using System;
using ArduinoUploader;
using ArduinoUploader.Hardware;

namespace SoftwareAssignment
{
    class Program
    {
        static void Main(string[] args)
        {
            var uploader = new ArduinoSketchUploader(
                new ArduinoSketchUploaderOptions()
                {
                     FileName = @"C:\Users\****\OneDrive\Desktop\Blink\Blink.hex",
                     PortName = "COM5",
                     ArduinoModel = ArduinoModel.Micro
                });

            uploader.UploadSketch();
        }
    }

我在Visual Studio2019中使用ArduinoUploader将.hex文件上传到arduino时收到异常。

代码语言:javascript
复制
System.IO.FileLoadException: 'Could not load file or assembly 'IntelHexFormatReader, Version=2.2.3.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)'

以下是详细信息

代码语言:javascript
复制
System.IO.FileLoadException
  HResult=0x80131040
  Message=Could not load file or assembly 'IntelHexFormatReader, Version=2.2.3.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
  Source=ArduinoUploader
  StackTrace:
   at ArduinoUploader.ArduinoSketchUploader.UploadSketch(IEnumerable`1 hexFileContents)
   at ArduinoUploader.ArduinoSketchUploader.UploadSketch()
   at SoftwareAssignment.Program.Main(String[] args) in C:\Users\****\source\repos\SoftwareAssignment\SoftwareAssignment\Program.cs:line 20

我不知道我应该如何解决这个问题,或者它是否是使用旧版本的.NET框架的ArduinoUploader包的结果,或者是否有任何方法可以修复这个问题。代码是用C#编写的。

EN

回答 2

Stack Overflow用户

发布于 2020-05-30 14:56:30

你可以用很多方法重新绑定程序集,对我个人来说,最简单的方法是在配置文件中。下面来自

https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/redirect-assembly-versions

代码语言:javascript
复制
<dependentAssembly>
  <assemblyIdentity name="someAssembly"
    publicKeyToken="32ab4ba45e0a69a1"
    culture="en-us" />
  <bindingRedirect oldVersion="7.0.0.0" 
newVersion="8.0.0.0" />
</dependentAssembly>

但是,请注意,不能保证您拥有的程序集将按照您的预期工作,无论它是旧的还是新的。我建议你试着找一个合适的。也就是说,如果你不能,那么上面就是你最好的选择。

票数 0
EN

Stack Overflow用户

发布于 2020-06-23 17:11:10

我听到你的声音了。您必须了解,您需要安装另一个NuGet包,即IntelHexReader。这是由同一个男孩写的,TwinEarthSoftware。在Visual Studio中搜索它。在定义所使用的目录时,您不需要包含它。与with.NET框架无关,它只是建议它需要2.2.3.0版本的IntelHexFileReader。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62097806

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档