ReflectionTypeLoadException occurs when running multiple unit tests (Nunit 3) #704

Closed
opened 2025-12-29 15:31:26 +01:00 by adam · 11 comments
Owner

Originally created by @R-Lamberson on GitHub (Jul 10, 2025).

Originally assigned to: @StefH on GitHub.

Describe the bug

I am getting the following error during the startup configuration of my tests when I run multiple tests with VS2022 Test Explorer. The overall application is running dotnet 8.0

System.Reflection.ReflectionTypeLoadException : Unable to load one or more of the requested types.
Method 'get_Category' in type 'HandlebarsDotNet.Helpers.XsltHelpers' from assembly 'HandlebarsDotNet.Helpers.Xslt, Version=2.4.6.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc' does not have an implementation.
----> System.TypeLoadException : Method 'get_Category' in type 'HandlebarsDotNet.Helpers.XsltHelpers' from assembly 'HandlebarsDotNet.Helpers.Xslt, Version=2.4.6.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc' does not have an implementation.

The stack strack points back to an internal line of code which uses Reflection to GetTypes() which appears to be triggering this exception

Image

when I run the tests individually I don't receive this error

Image

I found the assembly within the WireMock.net packages and it appears that the 'HandlebarsDotNet.Helpers.XsltHelpers' does not have an implementation

Image

Expected behavior:

All tests run without generating an exception

Test to reproduce

  • 1 use Reflection GetTypes to retrieve assembly information during the startup of the application
Originally created by @R-Lamberson on GitHub (Jul 10, 2025). Originally assigned to: @StefH on GitHub. ### Describe the bug I am getting the following error during the startup configuration of my tests when I run multiple tests with VS2022 Test Explorer. The overall application is running dotnet 8.0 _System.Reflection.ReflectionTypeLoadException : Unable to load one or more of the requested types. Method 'get_Category' in type 'HandlebarsDotNet.Helpers.XsltHelpers' from assembly 'HandlebarsDotNet.Helpers.Xslt, Version=2.4.6.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc' does not have an implementation. ----> System.TypeLoadException : Method 'get_Category' in type 'HandlebarsDotNet.Helpers.XsltHelpers' from assembly 'HandlebarsDotNet.Helpers.Xslt, Version=2.4.6.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc' does not have an implementation._ The stack strack points back to an internal line of code which uses Reflection to GetTypes() which appears to be triggering this exception <img width="1518" height="532" alt="Image" src="https://github.com/user-attachments/assets/542026bc-9ef8-46c7-a113-15fa55388d70" /> when I run the tests individually I don't receive this error <img width="1509" height="360" alt="Image" src="https://github.com/user-attachments/assets/bc746fdc-c60d-45da-b3a1-4ff5c91c8701" /> I found the assembly within the WireMock.net packages and it appears that the 'HandlebarsDotNet.Helpers.XsltHelpers' does not have an implementation <img width="274" height="321" alt="Image" src="https://github.com/user-attachments/assets/7e5a1cbc-60b5-431f-ab62-8c1dc0e80c65" /> ### Expected behavior: All tests run without generating an exception ### Test to reproduce - 1 use Reflection GetTypes to retrieve assembly information during the startup of the application
adam added the bug label 2025-12-29 15:31:26 +01:00
adam closed this issue 2025-12-29 15:31:26 +01:00
Author
Owner

@StefH commented on GitHub (Jul 10, 2025):

  • Wich version of WireMock are you using? Because latest WireMock depends on a newer version of Handlebars
  • and make sure you do not import manually another nuget version of Handlebars related packages.
@StefH commented on GitHub (Jul 10, 2025): - Wich version of WireMock are you using? Because latest WireMock depends on a newer version of Handlebars - and make sure you do not import manually another nuget version of Handlebars related packages.
Author
Owner

@R-Lamberson commented on GitHub (Jul 10, 2025):

Sorry should have included that, version 1.8.13 of WireMock.net, and confirmed that I do not have a manually imported reference to HandleBars.Net

@R-Lamberson commented on GitHub (Jul 10, 2025): Sorry should have included that, version 1.8.13 of WireMock.net, and confirmed that I do not have a manually imported reference to HandleBars.Net
Author
Owner

@StefH commented on GitHub (Jul 10, 2025):

Can you clean your solution / delete all bin and obj folders.

Also delete all handlebars related nuget folders from your nuget cache folder.

Restore all packages.

Rebuild and test again.

@StefH commented on GitHub (Jul 10, 2025): Can you clean your solution / delete all bin and obj folders. Also delete all handlebars related nuget folders from your nuget cache folder. Restore all packages. Rebuild and test again.
Author
Owner

@R-Lamberson commented on GitHub (Jul 11, 2025):

I just did those steps and I end up with the same behavior.

@R-Lamberson commented on GitHub (Jul 11, 2025): I just did those steps and I end up with the same behavior.
Author
Owner

@StefH commented on GitHub (Jul 12, 2025):

Do you still get error like:
'HandlebarsDotNet.Helpers.Xslt, Version=2.4.6.0 ?

@StefH commented on GitHub (Jul 12, 2025): Do you still get error like: 'HandlebarsDotNet.Helpers.Xslt, Version=**2.4.6.0** ?
Author
Owner

@R-Lamberson commented on GitHub (Jul 18, 2025):

Yes

Image
@R-Lamberson commented on GitHub (Jul 18, 2025): Yes <img width="1842" height="505" alt="Image" src="https://github.com/user-attachments/assets/f821ffee-51ca-4564-9977-5e199a59fc51" />
Author
Owner

@StefH commented on GitHub (Jul 18, 2025):

https://github.com/wiremock/WireMock.Net/pull/1332

@StefH commented on GitHub (Jul 18, 2025): https://github.com/wiremock/WireMock.Net/pull/1332
Author
Owner

@StefH commented on GitHub (Jul 18, 2025):

I found the issue.
New version will be released tomorrow.

@StefH commented on GitHub (Jul 18, 2025): I found the issue. New version will be released tomorrow.
Author
Owner

@R-Lamberson commented on GitHub (Jul 18, 2025):

I updated to version Wiremock.net 1.8.15, purged my bin and obj directories, cleaned my project and reran my tests and still hit the same behavior

test explorer error when running batch tests
Image

nuget manager showing version upgrade, and class view showing the Handlebars.DotNet.Helpers.Xslt class view without exposed classes
Image

@R-Lamberson commented on GitHub (Jul 18, 2025): I updated to version Wiremock.net 1.8.15, purged my bin and obj directories, cleaned my project and reran my tests and still hit the same behavior test explorer error when running batch tests <img width="1737" height="713" alt="Image" src="https://github.com/user-attachments/assets/ea52fc9d-84b4-4fa2-9740-628a2e3a3ecb" /> nuget manager showing version upgrade, and class view showing the Handlebars.DotNet.Helpers.Xslt class view without exposed classes <img width="1619" height="1032" alt="Image" src="https://github.com/user-attachments/assets/81fce250-5765-473d-b44d-778679532999" />
Author
Owner

@StefH commented on GitHub (Jul 18, 2025):

Please wait until next version tomorrow.
https://github.com/wiremock/WireMock.Net/blob/master/CHANGELOG.md

@StefH commented on GitHub (Jul 18, 2025): Please wait until next version tomorrow. https://github.com/wiremock/WireMock.Net/blob/master/CHANGELOG.md
Author
Owner

@R-Lamberson commented on GitHub (Jul 21, 2025):

Confirmed no longer getting an error from Handlebar Dotnet Helpers XSLT

@R-Lamberson commented on GitHub (Jul 21, 2025): Confirmed no longer getting an error from Handlebar Dotnet Helpers XSLT
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#704