[GH-ISSUE #31] Assembly reference not rewritten in XAML/BAML #27

Closed
opened 2026-02-25 21:30:29 +03:00 by kerem · 4 comments
Owner

Originally created by @JVimes on GitHub (Feb 16, 2017).
Original GitHub issue: https://github.com/brutaldev/StrongNameSigner/issues/31

Originally assigned to: @brutaldev on GitHub.

I think I found an assembly reference that's not being rewritten by StrongNameSigner, and I may know where it is.

Repro steps:

  1. Create a new "WPF Custom Control Library" project (not to be confused with "WPF User Control Library").
  2. Build it.
  3. Close the solution.
  4. Create a new "WPF Application" project.
  5. Configure the project for strong name signing (project settings > signing > etc.)
  6. Add a project reference to the custom control library DLL, built above.
  7. Add the Strong Name Signer nuget package to the project.
  8. In MainWindow.xaml, replace the grid tag with this (the xmlns value assumes the above DLL and it's .NET namespace are WpfCustomControlLibrary1, so doctor it if necessary):
    <Grid xmlns:mylib="clr-namespace:WpfCustomControlLibrary1;assembly=WpfCustomControlLibrary1">
        <mylib:CustomControl1/>
    </Grid>
    
  9. Build and run.

Expected: The application runs.
Actual: It throws an exception, "FileLoadException: Could not load file or assembly 'WpfCustomControlLibrary1, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)".

I may know where the un-rewritten reference is. I think it's an assembly self-reference in WpfCustomControlLibrary1.dll. That DLL contains a "generic.baml" resource (compiled from themes\generic.xaml in the project), and when I view it with dnSpy, there is a reference to the baml's own DLL, but with a null PublicKeyToken. I had to enable dnSpy's option: "View > Options > BAML decompiler > Disassemble BAML" to see the PublicKeyToken.

image

Edit: Looks like normal references (across assemblies) also aren't rewritten in XAML/BAML. Guessing XAML isn't yet supported.

Originally created by @JVimes on GitHub (Feb 16, 2017). Original GitHub issue: https://github.com/brutaldev/StrongNameSigner/issues/31 Originally assigned to: @brutaldev on GitHub. I think I found an assembly reference that's not being rewritten by StrongNameSigner, and I may know where it is. Repro steps: 1. Create a new "WPF Custom Control Library" project (not to be confused with "WPF User Control Library"). 1. Build it. 1. Close the solution. 1. Create a new "WPF Application" project. 1. Configure the project for strong name signing (project settings > signing > etc.) 1. Add a project reference to the custom control library DLL, built above. 1. Add the Strong Name Signer nuget package to the project. 1. In MainWindow.xaml, replace the grid tag with this (the `xmlns` value assumes the above DLL and it's .NET namespace are `WpfCustomControlLibrary1`, so doctor it if necessary): ``` <Grid xmlns:mylib="clr-namespace:WpfCustomControlLibrary1;assembly=WpfCustomControlLibrary1"> <mylib:CustomControl1/> </Grid> ``` 1. Build and run. **Expected:** The application runs. **Actual:** It throws an exception, "FileLoadException: Could not load file or assembly 'WpfCustomControlLibrary1, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)". **I *may* know where the un-rewritten reference is.** I think it's an assembly self-reference in WpfCustomControlLibrary1.dll. That DLL contains a "generic.baml" resource (compiled from themes\generic.xaml in the project), and when I view it with dnSpy, there is a reference to the baml's own DLL, but with a null PublicKeyToken. I had to enable dnSpy's option: "View > Options > BAML decompiler > Disassemble BAML" to see the PublicKeyToken. ![image](https://cloud.githubusercontent.com/assets/6148201/23002830/174b567a-f3aa-11e6-87b2-818d25f2b05e.png) **Edit:** Looks like normal references (across assemblies) also aren't rewritten in XAML/BAML. Guessing XAML isn't yet supported.
kerem 2026-02-25 21:30:29 +03:00
Author
Owner

@pp111 commented on GitHub (Aug 1, 2017):

Hello, I am having the same problem. Did you find a solution for this?

<!-- gh-comment-id:319408595 --> @pp111 commented on GitHub (Aug 1, 2017): Hello, I am having the same problem. Did you find a solution for this?
Author
Owner

@brutaldev commented on GitHub (Aug 1, 2017):

Not yet, no time for this project at the moment.

<!-- gh-comment-id:319409920 --> @brutaldev commented on GitHub (Aug 1, 2017): Not yet, no time for this project at the moment.
Author
Owner

@C1rdec commented on GitHub (Dec 1, 2017):

Any news on this issue?
Here is a simple repo: https://github.com/C1rdec/MaterialDesignStrongName

<!-- gh-comment-id:348629304 --> @C1rdec commented on GitHub (Dec 1, 2017): Any news on this issue? Here is a simple repo: https://github.com/C1rdec/MaterialDesignStrongName
Author
Owner

@brutaldev commented on GitHub (Dec 30, 2021):

Official release: https://www.nuget.org/packages/Brutal.Dev.StrongNameSigner/3.1.0

<!-- gh-comment-id:1003198925 --> @brutaldev commented on GitHub (Dec 30, 2021): Official release: https://www.nuget.org/packages/Brutal.Dev.StrongNameSigner/3.1.0
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/StrongNameSigner#27
No description provided.