John
John

Reputation: 1762

Prism WPF - Prism.Ioc.ContainerResolutionException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe

Im having an issue with prism:

Prism.Ioc.ContainerResolutionException: An unexpected error occurred while resolving 'Prism.Regions.SelectorRegionAdapter' ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

I am targeting .NET 4.8 in my project. I have tried installing the NUGET preview 6 of CompilerServices.

But nothing is helping resolve the issue.

Any suggestions?

Here is the full exception:

Prism.Ioc.ContainerResolutionException: An unexpected error occurred while resolving 'Prism.Regions.SelectorRegionAdapter' ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. at Unity.Builder.BuilderContext.Resolve(Type type, String name, InternalRegistration registration) at Unity.Builder.BuilderContext.Resolve(Type type, String name) at Unity.Builder.BuilderContext.Resolve(ParameterInfo parameter, Object value) at Unity.Processors.ConstructorProcessor.<>c__DisplayClass16_0.b__0(BuilderContext& c) at Unity.Processors.MemberProcessor2.<>c__DisplayClass8_0.<GetResolver>b__0(BuilderContext& c) at Unity.Processors.MemberProcessor2.<>c__DisplayClass8_0.b__0(BuilderContext& c) at Unity.Processors.MemberProcessor2.<>c__DisplayClass8_0.<GetResolver>b__0(BuilderContext& c) at Unity.Strategies.BuildPlanStrategy.PreBuildUp(BuilderContext& context) at Unity.UnityContainer.<>c.<.ctor>b__73_1(BuilderContext& context) at Unity.UnityContainer.Unity.IUnityContainer.Resolve(Type type, String name, ResolverOverride[] overrides) at Prism.Unity.UnityContainerExtension.Resolve(Type type, ValueTuple2[] parameters) --- End of inner exception stack trace --- at Prism.Unity.UnityContainerExtension.Resolve(Type type, ValueTuple`2[] parameters) at Prism.Ioc.IContainerProviderExtensions.Resolve[T](IContainerProvider provider) at Prism.Regions.RegionAdapterMappings.RegisterMappingTControl,TAdapter at Prism.PrismInitializationExtensions.RegisterDefaultRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings) at Prism.PrismBootstrapperBase.ConfigureRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings) at Prism.PrismBootstrapperBase.Initialize() at Prism.PrismBootstrapperBase.Run()

Upvotes: 0

Views: 2110

Answers (1)

John
John

Reputation: 1762

After a bit of experiment downgrading everything and updating incrementally I found that if I let the System.Runtime.CompilerServices.Unsafe package upgrade to the current stable version 5.0.0 then application throws the above exception. I have to downgrade to version 4.5.3 and then everything works as expected.

Package Manager still wants me to update System.Runtime.CompilerServices.Unsafe, unfortunately I don't know enough of how package manager works but it seems like another component (unity I guess since the exception is coming from the container) has a dependency on a particular version of this problematic DLL or perhaps its something else entirely.

Downgrading works for me. So this is my solution.

Upvotes: 0

Related Questions