Skip to content

Could not load file or assembly 'AgGateway.ADAPT.ApplicationDataModel' in .NET core project #279

Open

Description

@glenselle

Hi, I'm attempting to consume ADAPT and a plugin published by the Climate Corp for ADAPT but I'm having issues with my imports. Per the readme I'm attempting to run ADAPT with just the .NET core b/c I'm on a Mac. I have the dotnet CLI installed:

$ dotnet --version
2.2.207

I have a route which consumes the an ADAPT plugin and also pulls in ADAPT itself:

using ClimateADAPT;

using AgGateway.ADAPT.PluginManager;
using AgGateway.ADAPT.ApplicationDataModel.ADM;
using AgGateway.ADAPT.ApplicationDataModel.Common;
using AgGateway.ADAPT.ApplicationDataModel.Products;
using AgGateway.ADAPT.ApplicationDataModel.Logistics;
using AgGateway.ADAPT.ApplicationDataModel.Equipment;
using AgGateway.ADAPT.ApplicationDataModel.LoggedData;
using AgGateway.ADAPT.ApplicationDataModel.Representations;

namespace adapt_converter.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ClimateController : ControllerBase
    {
        // GET api/climate
        [HttpGet]
        public ActionResult<IEnumerable<string>> Get()
        {
            IPlugin ClimatePlugin = new ClimateADAPT.ClimateADAPTPlugin();
            return new string[] { "test 1", "test 2" };
        }
        // ...

But when I run my project and hit a route which tries to init the plugin, it fails with the following exception. Is it possible the DLL I pulled from the zip (on the releases page here) was not compiled to target just .NET core? Do I have to manually compile ADAPT from source and target only .NET core and use that DLL?

System.IO.FileLoadException: Could not load file or assembly 'AgGateway.ADAPT.ApplicationDataModel, Version=2.0.4.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'AgGateway.ADAPT.ApplicationDataModel, Version=2.0.4.0, Culture=neutral, PublicKeyToken=null'
   at adapt_converter.Controllers.ClimateController.Get()
   at lambda_method(Closure , Object , Object[] )
   at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

my .csproj file looks like this (and the project has dlls in the lib directory for each one of these):

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

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
    <RootNamespace>adapt_converter</RootNamespace>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
  </ItemGroup>

  <ItemGroup>
    <Reference Include="AgGateway.ADAPT.ApplicationDataModel">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>lib\AgGateway.ADAPT.ApplicationDataModel.dll</HintPath>
    </Reference>
    <Reference Include="AgGateway.ADAPT.PluginManager">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>lib\AgGateway.ADAPT.PluginManager.dll</HintPath>
    </Reference>
    <Reference Include="AgGateway.ADAPT.Representation">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>lib\AgGateway.ADAPT.Representation.dll</HintPath>
    </Reference>
    <Reference Include="ClimateADAPT">
      <HintPath>lib\ClimateADAPT.dll</HintPath>
    </Reference>

Activity

  1. JasonRoesbeke commented on Jun 8, 2020

    @JasonRoesbeke
    Contributor

    Hi @glenselle
    I think this issue is more related to referencing the correct library.
    You could look/search on stackoverflow:
    Quick search: The located assembly's manifest definition does not match the assembly reference

    Also check which ADAPT framework version your plugin references to, you may need to have an older version referenced to it.
    Note that you could also get the Nuget package of the ADAPT framework for different versions.

  2. glenselle commented on Jun 18, 2020

    @glenselle
    Author

    @JasonRoesbeke Hi Jason, thanks for your reply. Quick question on the README. When it says:

    It is possible to build the projects with just the .NET Core 2.x SDK if you use the .NET CLI and use the -Framework flag.

    1. Is "the projects" talking about building my app or building the ADAPT framework source?
    2. If it's ADAPT, does this mean I have to custom build ADAPT with just .NET core and then use that in my project? Or is there a .NET core-only variation of the package?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions