Skip to content

System.InvalidOperationException : A resolver is already set for the assembly. #1855

Closed
@AArnott

Description

@AArnott

After updating Nerdbank.GitVersioning to libgit2sharp 0.27.0-preview-0096, a great many of my tests are failing with this exception. Is it expected that SetConfigSearchPaths become callable-once-only?

Test Name:	GitContextLibGit2Tests.InitialDefaultState
Test FullName:	NerdBank.GitVersioning.Tests (net5.0).GitContextLibGit2Tests.GitContextLibGit2Tests.InitialDefaultState
Test Source:	D:\git\Nerdbank.GitVersioning\src\NerdBank.GitVersioning.Tests\GitContextTests.cs : line 40
Test Outcome:	Failed
Test Duration:	0:00:00

Test Name:	GitContextLibGit2Tests.InitialDefaultState
Test Outcome:	Failed
Result StackTrace:	
at LibGit2Sharp.Core.NativeMethods.git_repository_init_ext(git_repository*& repository, FilePath path, GitRepositoryInitOptions options)
   at LibGit2Sharp.Core.Proxy.git_repository_init_ext(FilePath workdirPath, FilePath gitdirPath, Boolean isBare)
   at LibGit2Sharp.Repository.Init(String path, Boolean isBare)
   at LibGit2Sharp.Repository.Init(String path)
   at RepoTestBase.InitializeSourceControl(String repoPath, Boolean withInitialCommit) in D:\git\Nerdbank.GitVersioning\src\NerdBank.GitVersioning.Tests\RepoTestBase.cs:line 108
   at RepoTestBase.InitializeSourceControl(Boolean withInitialCommit) in D:\git\Nerdbank.GitVersioning\src\NerdBank.GitVersioning.Tests\RepoTestBase.cs:line 102
   at GitContextTests..ctor(ITestOutputHelper logger) in D:\git\Nerdbank.GitVersioning\src\NerdBank.GitVersioning.Tests\GitContextTests.cs:line 35
   at GitContextLibGit2Tests..ctor(ITestOutputHelper logger) in D:\git\Nerdbank.GitVersioning\src\NerdBank.GitVersioning.Tests\GitContextTests.cs:line 23
----- Inner Stack Trace -----
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at LibGit2Sharp.Core.NativeMethods.TryUseNativeLibrary()
   at LibGit2Sharp.Core.NativeMethods..cctor()
----- Inner Stack Trace -----
   at System.Runtime.InteropServices.NativeLibrary.SetDllImportResolver(Assembly assembly, DllImportResolver resolver)
Result Message:	
System.TypeInitializationException : The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
---- System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
-------- System.InvalidOperationException : A resolver is already set for the assembly.

Originally posted by @AArnott in #1618 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions