Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.MissingMethodException on testrun after Upgrade to v3.0.* #443

Closed
ph1f1 opened this issue Mar 20, 2025 · 6 comments
Closed

System.MissingMethodException on testrun after Upgrade to v3.0.* #443

ph1f1 opened this issue Mar 20, 2025 · 6 comments
Labels

Comments

@ph1f1
Copy link

ph1f1 commented Mar 20, 2025

I just upgraded the xunit.runner.visualstudio package from 2.8.2 to 3.0.2.
After this upgrade the Build on our OnPremise Azure DevOps server throws this exception on test execution:

[FATAL ERROR] System.MissingMethodException
[xUnit.net 00:00:02.96]       System.MissingMethodException : Method not found: 'Microsoft.VisualStudio.TestPlatform.ObjectModel.UriDataAttachment Microsoft.VisualStudio.TestPlatform.ObjectModel.UriDataAttachment.CreateFrom(System.String, System.String)'.
[xUnit.net 00:00:02.96]       Stack Trace:
[xUnit.net 00:00:02.96]         
[xUnit.net 00:00:02.96]         Server stack trace: 
[xUnit.net 00:00:02.96]            at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
[xUnit.net 00:00:02.96]            at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
[xUnit.net 00:00:02.96]         
[xUnit.net 00:00:02.96]         Exception rethrown at [0]: 
[xUnit.net 00:00:02.96]            at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
[xUnit.net 00:00:02.96]            at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
[xUnit.net 00:00:02.96] Catastrophic failure: System.MissingMethodException : Method not found: 'Microsoft.VisualStudio.TestPlatform.ObjectModel.UriDataAttachment Microsoft.VisualStudio.TestPlatform.ObjectModel.UriDataAttachment.CreateFrom(System.String, System.String)'.

With version 2.8.2 everything worked. Also the tests run as excepted on my development client with the 3.0.2 version. Am I missing a package for xunit to run?

Target framework: .Net Framework 4.8.1
Microsoft.TestPlatform.ObjectModel Package version: 17.13.0

@bradwilson
Copy link
Member

It's not clear what's happening here.

UriDataAttachment is provided by Microsoft.TestPlatform.ObjectModel, which is provided by the ambient VSTest execution environment. My guess is you're using a .NET SDK that's too old to provide UriDataAttachment, which appears to have been added in 2022. Which .NET SDK are you using? You may not be able to upgrade xunit.runner.visualstudio if you can't resolve the issue with the out-of-date .NET SDK.

@ph1f1
Copy link
Author

ph1f1 commented Mar 21, 2025

Thank you for your quick reply.
The target framework for the application and the testproject is .net Framework 4.8.1
I double checked the added Nuget package version of Microsoft.TestPlatform.Objectmodel which is 17.13.0
Microsoft.VisualStudio.TestPlatform.ObjectModel.dll also gets copied to the bin folder in the correct version
.Net 9.0 SDK is installed on both machines too.

The point i don't get is, it works on the development client but not in the Azure Devops Server build pipeline.

@bradwilson
Copy link
Member

Using .NET Framework is irrelevant; what matters is the version of the .NET SDK (aka, the thing that's providing dotnet.exe) because that's where the version of dotnet test comes from. It's independent of .NET Framework, which ships as part of the OS.

Microsoft.TestPlatform.ObjectModel doesn't come from a NuGet reference, because it's expected to be part of the ambient execution environment. I don't believe adding a NuGet reference has any impact on the issue, since it needs to be the ObjectModel DLL that VSTest is using (which is not something that the third party runner can control). The VSTest team would be able to answer better than me. It's probably worth opening this issue with them to see what their suggestion is.

@ph1f1
Copy link
Author

ph1f1 commented Mar 21, 2025

Thank you for the insights.

For your information and everyone else who might have this issue:
After checking the Azure DevOps installation prior to me installing the .Net SDK 9.0 manually there was only .Net SDK 8.0 installed which contains the Microsoft.VisualStudio.TestPlatform.ObjectModel.dll in the version 17.8.0. According to the xunit.runner.visualstudio dependencies at least version 17.12.0 is needed. I guess this causes the issue I'm having.

@ph1f1
Copy link
Author

ph1f1 commented Mar 21, 2025

I found the solution to this.
According to the documentation of VSTest Runner Task of the Azure DevOps Server build pipeline you can set the input vsTestVersion to toolsInstaller which allows the Task to target multiple target frameworks at a time.

After that, the tests worked as expected.

@ph1f1 ph1f1 closed this as completed Mar 21, 2025
@bradwilson
Copy link
Member

bradwilson commented Mar 21, 2025

I am able to find the method that you're missing all the way back to 17.0.0 of Microsoft.TestPlatform.ObjectModel, so I don't understand why it's missing when you have VSTest 17.8.0. I will still strongly recommend that you contact the VSTest team to get a better understanding of why this isn't working in your environment.

(To be clear: I stopped searching beyond 17.0.0, since that's the first version that shipped in alignment with VS2022, which is our minimum supported version of VS.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants