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

Repository.Discover() throws exception in Release mode, but not Debug mode #2122

Open
brantnej opened this issue Aug 27, 2024 · 2 comments
Open

Comments

@brantnej
Copy link

I'm making a VSIX extension that does Git operations, I ran into this issue while trying to get the corresponding repo for the active document. When testing in the LLVM repo, doing Repository.Discover() on the active file C:\Users\<my_user_name>\source\repos\llvm-project\clang\lib\Format\UnwrappedLineParser.cpp throws in Release mode, but on Debug mode it correctly gets the repository path of C:\Users\<my_user_name>\source\repos\llvm-project\.git\

Reproduction steps

  • Create Visual Studio Extension project and add a command, set build to Release mode
  • Within the command, get active document with DTE applicationObject = (DTE)await AsyncServiceProvider.GlobalProvider.GetServiceAsync(typeof(SDTE));
  • Get full file path with var filePath = applicationObject.ActiveDocument.FullName
  • Call var repoPath = Repository.Discover(filePath)

Expected behavior

repoPath holds the path of the repository

Actual behavior

Exception is thrown with the message The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.

Version of LibGit2Sharp (release number or SHA1)

0.30.0

Operating system(s) tested; .NET runtime tested

Windows 11, .NET Framework 4.8

@brantnej
Copy link
Author

brantnej commented Aug 27, 2024

If I hard code the repository path, then the constructor new Repository(repoPath) also throws an exception with The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception in Release mode only. It is likely to do with something in my configuration but I would like to know what could be happening here.

@brantnej
Copy link
Author

It appears that the inner exception says Unable to load DLL 'git2-a2bde63': The specified module could not be found which is a duplicate of https://stackoverflow.com/questions/50586936/the-type-initializer-for-libgit2sharp-core-nativemethods-threw-an-exception , but even after copying the file over to the release folder it still doesn't work

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

No branches or pull requests

1 participant