peachpiecompiler / peachpie

PeachPie - the PHP compiler and runtime for .NET and .NET Core
https://www.peachpie.io
Apache License 2.0
2.33k stars 202 forks source link

Could not load type 'ThrowHandler' when referencing Peachpie.Library.PDO.PgSQL version 1.0.0-dev #1082

Closed kripper closed 1 year ago

kripper commented 1 year ago

I'm getting the error Could not load type 'ThrowHandler' when trying to reference Peachpie.Library.PDO.PgSQL version 1.0.0-dev (compiled using latest upstream version):

Unhandled exception. System.TypeLoadException: Could not load type 'ThrowHandler' from assembly 'Peachpie.Runtime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5b4bee2bf1f98593'.
   at Peachpie.AspNetCore.Web.PhpHandlerMiddleware.ConfigureLogger(IPhpOptions options, ILoggerFactory factory)
   at Peachpie.AspNetCore.Web.PhpHandlerMiddleware..ctor(RequestDelegate next, IWebHostEnvironment hostingEnv, IServiceProvider services, PhpHandlerConfiguration configuration)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
   at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass5_0.<UseMiddleware>b__0(RequestDelegate next)
   at Microsoft.AspNetCore.Builder.ApplicationBuilder.Build()
   at Microsoft.AspNetCore.Hosting.WebHost.BuildApplication()
   at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   at (my code)

Is it broken or am I doing something wrong?

This are my build files:

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

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

  <ItemGroup>
    <PackageReference Include="Peachpie.AspNetCore.Web" Version="1.0.0-dev" />
    <ProjectReference Include="..\Website\Website.msbuildproj" />
  </ItemGroup>

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

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

  <ItemGroup>
    <ProjectReference Include="..\Website\Website.msbuildproj" />
    <!--
    <PackageReference Include="Peachpie.AspNetCore.Web" Version="1.0.6" />
    <PackageReference Include="Peachpie.Library.PDO.PgSQL" Version="1.0.6" />
    -->
    <PackageReference Include="Peachpie.AspNetCore.Web" Version="1.0.0-dev" />
    <PackageReference Include="Peachpie.Library.PDO.PgSQL" Version="1.0.0-dev" /> <----- fails
  </ItemGroup>

</Project>
kripper commented 1 year ago

Maybe realted with a version mismatch?

warning NU1603: Server depends on Peachpie.Library.PDO.PgSQL (>= 1.0.0-dev) but Peachpie.Library.PDO.PgSQL 1.0.0-dev was not found. An approximate best match of Peachpie.Library.PDO.PgSQL 1.0.0-preview1 was resolved.
kripper commented 1 year ago

It was a version mismatch, because it works fine when referencing latest nuget:

<PackageReference Include="Peachpie.Library.PDO.PgSQL" Version="1.2.0-r14819" />

I added Peachpie.Library.PDO.PgSQL to build\update-cache.ps1 but it's still not using my local compiled assemblies.

kripper commented 1 year ago

Fixed here: https://github.com/peachpiecompiler/peachpie/pull/1066