dotnet / orleans

Cloud Native application framework for .NET
https://docs.microsoft.com/dotnet/orleans
MIT License
10.01k stars 2.02k forks source link

Could not load type 'Orleans.CodeGeneration.KnownAssemblyAttribute' in Orleans 8.1.0 nuget packages #8956

Open UladzimirVyaziginTR opened 4 months ago

UladzimirVyaziginTR commented 4 months ago

I am trying to test my code on .NET 8 via TestCluster using Microsoft.Orleans.TestingHost 8.1.0 nuget package according to the instructions from https://learn.microsoft.com/en-us/dotnet/orleans/implementation/testing. My Fixture, CollectionFixture and Exception are represented below.

public sealed class OrleansInMemoryClusterFixture : IDisposable
{
    public TestCluster Cluster { get; } = new TestClusterBuilder().Build();

    public OrleansInMemoryClusterFixture() => Cluster.Deploy();

    public void Dispose() => Cluster.StopAllSilos();
}
[CollectionDefinition(nameof(OrleansInMemoryClusterCollection))]
public class OrleansInMemoryClusterCollection : ICollectionFixture<OrleansInMemoryClusterFixture>;
System.AggregateException : One or more errors occurred. (Could not load type 'Orleans.CodeGeneration.KnownAssemblyAttribute' from assembly 'Orleans.Core.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null'.) (The following constructor parameters did not have matching fixture data: OrleansInMemoryClusterFixture orleansInMemoryClusterFixture)
---- System.TypeLoadException : Could not load type 'Orleans.CodeGeneration.KnownAssemblyAttribute' from assembly 'Orleans.Core.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null'.
---- The following constructor parameters did not have matching fixture data: OrleansInMemoryClusterFixture orleansInMemoryClusterFixture

  Stack Trace: 
----- Inner Stack Trace #1 (System.TypeLoadException) -----
ModuleHandle.ResolveType(QCallModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctorWithParameters, Boolean& isVarArg)
CustomAttribute.IsCustomAttributeDefined(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Int32 attributeCtorToken, Boolean mustBeInheritable)
CustomAttribute.IsDefined(RuntimeAssembly assembly, RuntimeType caType)
ReferencedAssemblyProvider.AddFromAssemblyLoadContext(HashSet`1 parts, Assembly assembly) line 82
ReferencedAssemblyProvider.GetRelevantAssemblies() line 23
ServiceCollectionExtensions.AddSerializer(IServiceCollection services, Action`1 configure) line 40
<10 more frames...>
TestCluster.DefaultCreateSiloAsync(String siloName, IConfiguration configuration) line 661
TestCluster.StartSiloAsync(Int32 instanceNumber, TestClusterOptions clusterOptions, IReadOnlyList`1 configurationOverrides, Boolean startSiloOnNewPort) line 724
TestCluster.InitializeAsync() line 636
TestCluster.DeployAsync() line 167
TestCluster.DeployAsync() line 202
TestCluster.Deploy() line 151
OrleansInMemoryClusterFixture.ctor() line 10
RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
ReubenBond commented 3 months ago

This looks like an assembly version mismatch. Are you sure that all packages have been upgraded to v8.1.0?

UladzimirVyaziginTR commented 3 months ago

image