Prism icon indicating copy to clipboard operation
Prism copied to clipboard

[BUG] Prism.Container.Abstractions, Version=9.0.107.57918, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59 Or one of its dependencies. Strong name verification failed

Open weiwei11245 opened this issue 1 year ago • 22 comments

Description

When I upgraded from Prism 8 to 9, this error occurred

An unprocessed exception of type 'System. IO. FileLoadException' is in an unknown module. Occurred in the middle Failed to load file or assembly 'Prism. Container. Abstracts, Version=9.0.107.57918, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)

Steps to Reproduce

What happens during program startup

Platform with bug

WPF

Affected platforms

Windows

Did you find any workaround?

No response

Relevant log output

No response

weiwei11245 avatar Aug 23 '24 03:08 weiwei11245

I have exactly the same issue, Exception thrown: 'System.IO.FileLoadException' in PresentationFramework.dll An unhandled exception of type 'System.IO.FileLoadException' occurred in PresentationFramework.dll Could not load file or assembly 'Prism.Container.Abstractions, Version=9.0.107.57918, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)

bin\Release>sn -v Prism.Container.Abstractions.dll

Microsoft (R) .NET Framework Strong Name Utility Version 4.0.30319.0 Copyright (c) Microsoft Corporation. All rights reserved.

Prism.Container.Abstractions.dll is a delay-signed or test-signed assembly

volvo245r avatar Aug 23 '24 10:08 volvo245r

same error

qtbui159 avatar Aug 29 '24 17:08 qtbui159

Yes we're aware of the issue though I'm not sure why this broke. We've been using the same logic to strong name the assemblies since the beginning of Prism.

dansiegel avatar Aug 30 '24 00:08 dansiegel

@dansiegel in release mode Similar error with the Prism.DryIoc.Maui package with latest Version=9.0.537 In Android.

Error (10255) / AndroidRuntime: android.runtime.JavaProxyThrowable: [System.TypeLoadException]: Could not resolve type with token 01000061 from typeref (expected class 'System.ExceptionHelper' in assembly 'Prism.Container.Abstractions, Version=9.0.106.9543, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59')

letscodewithkalyan avatar Sep 02 '24 11:09 letscodewithkalyan

registry trick from https://stackoverflow.com/questions/403731/strong-name-validation-failed worked for me

tkcecek avatar Sep 03 '24 13:09 tkcecek

As of today, this BUG still exists. I have no choice but to roll back to version 8.1.97, and then it can run normally. I have tried various methods. 【强名称验证失败】

Mr-Cat-r avatar Sep 04 '24 01:09 Mr-Cat-r

Correct it still exists. And we're working on some back channels to fix this with Microsoft because there is no reason for this to have broken. We haven't changed anything.

dansiegel avatar Sep 04 '24 02:09 dansiegel

Using ClickOnce, for .Net Framework 4.8, latest deployment of Prism works like a charm, however, when prism version 8.x is updated to version 9.x, this error is raised.

When a [signed] assembly is deployed using ClickOnce, its updates are also hash-checked by ClickOnce security with the previous updates. In its subsequent version if the assembly is signed with different certificate, although it compiles successfully, assembly signing error is raised by ClickOnce when updates are deployed on client machine.

Please check if it helps.

smsaleem avatar Sep 10 '24 06:09 smsaleem

Same problem here, we have to downgrade to 8.1 too.

AbraxasCSharp avatar Sep 10 '24 08:09 AbraxasCSharp

We have two Prism exes building in the same solution. Once we updated to 9 one had this problem and the other did not. It turns out that while both had a platform target of "Any CPU" the one that failed had the "Prefer 32-bit" checkbox selected. I cleared that checkbox and the problem went away. YMMV!

Addendum: Once the apps built and ran (no detected problems BTW!) I ran unit tests. Three unit test assemblies also threw strong name errors, all were compiled x86. Switching to AnyCPU fixed them. Something 32/64 bit going on here?

nvonada avatar Oct 07 '24 16:10 nvonada

I'm still encountering the error described in the issue, any additional advice or workarounds would be greatly appreciated

toumir avatar Oct 10 '24 19:10 toumir

Unfortunately I haven't been able to resolve this with Microsoft yet so there isn't an update to give. All I can tell you is that the process we use for the strong naming hasn't changed in years so we're not sure why the tooling isn't doing what it's supposed to.

dansiegel avatar Oct 10 '24 19:10 dansiegel

I've the same issue after updating from 8.1.97 to 9.0.537.

WPF application Sdk="Microsoft.NET.Sdk" TargetFramework=net472 Win11 VisualStudio 17.10.3

Bodewes avatar Oct 16 '24 12:10 Bodewes

We have two Prism exes building in the same solution. Once we updated to 9 one had this problem and the other did not. It turns out that while both had a platform target of "Any CPU" the one that failed had the "Prefer 32-bit" checkbox selected. I cleared that checkbox and the problem went away. YMMV!

Addendum: Once the apps built and ran (no detected problems BTW!) I ran unit tests. Three unit test assemblies also threw strong name errors, all were compiled x86. Switching to AnyCPU fixed them. Something 32/64 bit going on here?

OK, I thought I had this beat but my PR build is blowing up on Azure DevOps. 2/3 of my unit tests will not run on the build server due to this error. I am going to try a couple of things but I might be defeated here.

nvonada avatar Oct 16 '24 16:10 nvonada

Is everyone here reporting this issue using WPF?

What if we just removed strong name signing. Strong-names are left over from previous eras of .NET where needed to differentiate between code that was trusted, versus code that was untrusted.

Strong naming is about identity not security.

Thoughts?

brianlagunas avatar Oct 16 '24 18:10 brianlagunas

Yes I'm reporting it for WPF. Removing the strong name signing would help a lot. I can only support that Strong naming is about identity.

AbraxasCSharp avatar Oct 16 '24 18:10 AbraxasCSharp

ClickOnce needs strong naming. Is there anyway to bypass it ?

smsaleem avatar Oct 17 '24 04:10 smsaleem

You can temporarily disable strong name validation for the delay-signed assembly using the sn.exe tool.

sn -Vr Prism.Container.Abstractions,40ee6c3a2184dc59

After disabling strong name validation, rebuild your project and run it again. This should bypass the strong name validation failure and allow the assembly to load properly.

brianlagunas avatar Oct 17 '24 13:10 brianlagunas

You can temporarily disable strong name validation for the delay-signed assembly using the sn.exe tool.

sn -Vr Prism.Container.Abstractions,40ee6c3a2184dc59

After disabling strong name validation, rebuild your project and run it again. This should bypass the strong name validation failure and allow the assembly to load properly.

If I go this route, I have to do this on every PC runnning the WPF application? I don't think Corparate(tm) will like that.

Bodewes avatar Oct 17 '24 14:10 Bodewes

Hi @brianlagunas,

Thanks for the tip on disabling strong name validation. Unfortunately, I'm still encountering the System.IO.FileLoadException even after turning it off.

The issue seems to be related to using the latest versions of the Prism packages:

Prism.Container.Abstractions (version: 9.0.107) Prism.Container.DryIoc (version: 9.0.107) Prism.Core (version: 9.0.537) Prism.DryIoc (version: 9.0.537) Prism.Events (version: 9.0.537) Prism.Wpf (version: 9.0.537) When running the application, we get a strange exception indicating a dependency on an older version (9.0.106.9543) of Prism.Container.Abstractions.

Here's the exact error message:

System.IO.FileLoadException: 'Could not load file or assembly 'Prism.Container.Abstractions, Version=9.0.106.9543, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'  

Any ideas on how to resolve this version mismatch?

toumir avatar Oct 17 '24 14:10 toumir

Maybe if we have access to the Source code for these packages (Prism.Container.Abstractions and Prism.Container.DryIoc), we can build unsigned versions of these assemblies, as the source repository for these assemblies is not available (https://github.com/PrismLibrary/Prism.Containers).

chk040399 avatar Oct 20 '24 14:10 chk040399

@chk040399 I can sympathize with your frustration. The reality is that we actually haven't changed anything about the way that we handle package signing and strong naming, and it wasn't until we finally released the GA that this was reported. This should highlight to the community the importance of using preview packages so that we can catch issues like this sooner.

Something in the build system has caused the problem and we are still looking into this. While I cannot tell you exactly when we will be able to resolve it, we are continuing to look into this.

dansiegel avatar Oct 20 '24 15:10 dansiegel

registry trick from https://stackoverflow.com/questions/403731/strong-name-validation-failed worked for me

So far it looks like a great solution.

Open the command prompt as administrator and enter following commands:

reg DELETE "HKLM\Software\Microsoft\StrongName\Verification" /f
reg ADD "HKLM\Software\Microsoft\StrongName\Verification\*,*" /f
reg DELETE "HKLM\Software\Wow6432Node\Microsoft\StrongName\Verification" /f
reg ADD "HKLM\Software\Wow6432Node\Microsoft\StrongName\Verification\*,*" /f

DevMercenary avatar Nov 04 '24 16:11 DevMercenary

I can also report haivng this after updating to 9.0.107.

The registry trick from @DevMercenary has seemingly done the trick for development, however like @Bodewes this isn't a great option for production.

If you need anything from me to test\replicate\verify please let me know and I can do whatever needed.

Shannon-roos avatar Nov 19 '24 06:11 Shannon-roos

Same issue here using WPF. I only have this issue with version 9.0.537. With 9.0.401-pre everything works fine.

maho123456emer avatar Dec 10 '24 09:12 maho123456emer

Prism.Container.Abstractions (version: 9.0.107)

Same error - 'System.IO.FileLoadException' I am getting for Prism.Container.Abstractions (version: 9.0.107).

AnilNalawade avatar Dec 18 '24 11:12 AnilNalawade

Mark it and wait for the problem to be solved

bart-fan avatar Dec 19 '24 03:12 bart-fan

Mark it and wait for the problem to be solved

Now .use 8.1.97

bart-fan avatar Jan 02 '25 06:01 bart-fan

Has there been a resolution to this problem? I have gone through a lot of effort to update from a very old Prism to the latest, but this problem is starting to look like a showstopper for the whole update project.

dspear avatar Jan 13 '25 15:01 dspear

@dspear You can use the preview version 9.0.401-pre which was the release before the current version.

brianlagunas avatar Jan 13 '25 15:01 brianlagunas