dynamicexpresso / DynamicExpresso

C# expressions interpreter
http://dynamic-expresso.azurewebsites.net/
MIT License
1.98k stars 371 forks source link

Could not load file or assembly #228

Closed ZETA-Development closed 2 years ago

ZETA-Development commented 2 years ago

Could not load file or assembly 'DynamicExpresso.Core.resources, Version=2.11.0.0, Culture=en-US, PublicKeyToken=null'. The system cannot find the file specified.

I'm working on .netcore 5 platform. Added this package but get the error above. I tried to remove and then add again, reopen vscode, delete build folder so far.

why am i getting this error?

metoule commented 2 years ago

I can't reproduce your issue. Can you share your .csproj file ? Can you also check if it works with DynamicExpresso.Core version 2.10.0 ?

ZETA-Development commented 2 years ago
<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
   <PackageReference Include="DynamicExpresso.Core" Version="2.9.8" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.Certificate" Version="5.0.13" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.13" />
    <PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.13" />
   <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.13" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.13">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
     <PrivateAssets>all</PrivateAssets>
   </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.13" />
   <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.13">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Npgsql" Version="6.0.2" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
    <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.15.0" />
    <Reference Include="3cxpscomcpp2">
      <HintPath Condition="Exists('..\..\..\..\Program Files\3CX Phone System\Bin\')">..\..\..\..\Program Files\3CX Phone System\Bin\3cxpscomcpp2.dll</HintPath>
      <HintPath Condition="Exists('/usr/lib/3cxpbx/')">/usr/lib/3cxpbx/3cxpscomcpp2.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <None Update="Queries\*.*">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>

</Project>

It was on version 2.10.0. I also tried some of different versions, no luck! It's working on console app very well but not in api project.

metoule commented 2 years ago

I created a brand new project for ASP.NET Core Web API using .NET5, with the following .csproj:

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

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="DynamicExpresso.Core" Version="2.11.0" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.Certificate" Version="5.0.13" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.13" />
    <PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.13" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.13" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.13">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.13" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.13">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Npgsql" Version="6.0.2" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
    <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.15.0" />
  </ItemGroup>

</Project>

and I can't reproduce your issue :(

ZETA-Development commented 2 years ago

First of all, thanks for your replies :)

I found the cause of this error.

static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            var name = new AssemblyName(args.Name).Name;
            if (name == "3cxpscomcpp2")
            {
                string binPath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
                    ? @"C:\Program Files\3CX Phone System\Bin\3cxpscomcpp2.dll"
                    : @"/usr/lib/3cxpbx/3cxpscomcpp2.dll";
                return Assembly.LoadFrom(binPath);
            }
            return null;
            // else
            //     throw new FileNotFoundException();
        }

I was assined the method above on AssemblyResolve event. throwing FileNotFoundException was the cause! I added return null and it's working now.

Thanks again for your time.

metoule commented 2 years ago

OK, thanks for letting me know! I'll close this issue then.