1

I am currently developing an .NET5 console application using JetBrains Rider 2020.3 as IDE. The application communicates with multiple AVT cameras over the Vimba API. So I installed the Vimba SDK v4.2 and copied the VimbaNET.dll into my solutions folder and referenced it in the projects of the solution. The application runs fine on my development desktop pc and two other pc's I tested. But on the target notebook (and another nb I also tested) it's throwing a BadImageFormatException, saying it's trying to load a file in a wrong format:

System.BadImageFormatException: Could not load file or assembly 'VimbaNET, Version=1.8.3.29465, Culture=neutral, PublicKeyToken=96b729f24f119b9a'. Es wurde versucht, eine Datei mit einem falschen Format zu laden.
File name: 'VimbaNET, Version=1.8.3.29465, Culture=neutral, PublicKeyToken=96b729f24f119b9a'
   at ShapeAndColor.AvtFrameGrabber.FrameGrabber.Startup()
   at ShapeAndColor.AvtFrameGrabber.Program.Main(String[] args) in C:\Users\myname\RiderProjects\avtframegrabber\AvtFrameGrabber\Program.cs:line 32

The VimbaNET.dll is a x64 DLL and I set my target runtime to win-x64. The OS on all systems I tested is Win10 x64 with .NET5 x64 Desktop runtime (or SDK respectively) installed. I also tried to build an x86 version of the application with the 32bit VimbaNET.dll also included in the VimbaSDK. I also tried an 64bit build with the 32bit VimbaNET.dll.

So I'm pretty sure it is not a conflict of a 64bit process trying to load 32bit dll or vice versa.

Here are the configs of the projects in the solution (both are referencing the VimbaNET.dll):

AvtFrameGrabber.csproj

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net5.0</TargetFramework>
        <RootNamespace>ShapeAndColor.AvtFrameGrabber</RootNamespace>
        <Configurations>Release;Debug</Configurations>
        <Platforms>x64</Platforms>
        <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
    </PropertyGroup>

    <PropertyGroup Condition=" '$(TargetFramework)' == 'net46' ">
        <PreserveCompilationContext>true</PreserveCompilationContext>
    </PropertyGroup>

    <ItemGroup>
      <PackageReference Include="EasyConsole" Version="1.1.0" />
      <PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
      <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
      <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="5.0.0" />
      <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
      <PackageReference Include="Serilog" Version="2.10.0" />
      <PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
      <PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
      <PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
      <PackageReference Include="System.Drawing.Common" Version="5.0.0" />
    </ItemGroup>

    <ItemGroup>
      <ProjectReference Include="..\AvtFrameGrabber.Utils\AvtFrameGrabber.Utils.csproj" />
    </ItemGroup>

    <ItemGroup>
      <None Update="appsettings.json">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </None>
    </ItemGroup>

    <ItemGroup>
      <Reference Include="VimbaNET, Version=1.8.3.29465, Culture=neutral, PublicKeyToken=96b729f24f119b9a">
        <HintPath>libs\VimbaNET.dll</HintPath>
      </Reference>
    </ItemGroup>

</Project>

AvtFrameGrabber.Utils.csproj

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net5.0</TargetFramework>
        <RootNamespace>ShapeAndColor.AvtFrameGrabber.Utils</RootNamespace>
        <Configurations>Release;Debug</Configurations>
        <Platforms>x64</Platforms>
        <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Serilog.Sinks.Async" Version="1.4.0" />
        <PackageReference Include="System.Drawing.Common" Version="5.0.0" />
        <PackageReference Include="Serilog" Version="2.10.0" />
        <PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
        <PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
        <PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
    </ItemGroup>

    <ItemGroup>
      <Reference Include="VimbaNET, Version=1.8.3.29465, Culture=neutral, PublicKeyToken=96b729f24f119b9a">
        <HintPath>..\AvtFrameGrabber\libs\VimbaNET.dll</HintPath>
      </Reference>
    </ItemGroup>
</Project>

I'm stuck with this for days and I have no clue why it's running on the desktop pcs and not the notebooks. Do you have an idea what to do?

  • [Another victim](https://stackoverflow.com/questions/59892576/c-sharp-program-can-run-on-development-laptop-but-cannot-on-another), somebody ought to contact the product owner. – Hans Passant Dec 16 '20 at 15:16

1 Answers1

1

Installing .NET 3.5 solves the problem since Vimba SDK has a dependency to .NET 2 (no, not .NET Standard or Core 2). .NET 3.5 includes .NET 2 runtime.

Batuhan
  • 100
  • 10