AnkhSVN
AnkhSVN copied to clipboard
Exception in Visual Studio 2022 (version 17.2.0) when opening a solution that uses AnhSvn
I've successfully used AnkhSVN version 2.9.87 with Visual Studio 2022 (internal version < 17.2). Now I've updated to VS2022 version 17.2. When I now open a solution file that uses AnkhSvn I get this exception:
System.InvalidCastException: Unable to cast object of type 'Microsoft.VisualStudio.CommonIDE.Solutions.SolutionPropertyBag' to type 'Ankh.Scc.Native.ICOMPropertyBag'.
at Ankh.VSPackage.AnkhSvnPackage.ReadSolutionProps(IVsHierarchy pHierarchy, String pszProjectName, String pszProjectMk, String pszKey, Int32 fPreLoad, IPropertyBag pPropBag)
Afterwards Visual Studio freezes.
I am receiving the same error, but I'm able to continue working and even Ankh seems to be working ok.
Additionally i get a message that "One or more project in the solution were not loaded correctly". But I cannot an unloaded project though. In the output window from "Solution" i get the message: "Some of the properties associated with the solution could not be read."
I am not sure if this is related to AnkhSVN.
I rebuilt the package with latest Microsoft.VisualStudio.OLE.Interop package and that seem to solve the issue.
This appears to be the same issue as https://github.com/AmpScm/AnkhSVN/issues/44
After reading #44 I tried the vsix from the MSBuild 121 action and can confirm that I no longer get the exception.
Yes, after #44 now is working, thanks
MSBuild 121 action has expired so there's not a solution in this moment. Please, update the VSIX on the Marketplace if possible. Thanks!
Hi, I have the same problem with VS2022, please fix it.
The problem seems to be the (as the error hints) the propertybag within the solution file
So a work around of this issue:
- You have a "solution.sln" created with VS 2019 or earlier
- In that solution you may have the following entry (may be something at the end):
GlobalSection(SubversionScc) = preSolution Svn-Managed = True Manager = AnkhSVN2019 - Subversion Support for Visual Studio EndGlobalSection
- As the VS2022 doesn't support 2019 an AnkhSvn2019-class couldn't be found by VS2022 (assumption)
- After removing the whole GlobalSection, the solution can be opened without popups.
Further: If you've installed both but want the right for the visual studio version, I suggest making the following:
- "solution.vs2019.sln" with GlobalSection(SubversionScc) ect and the VisualStudioVersion = ... at the top of the file set to VS2019 version (16.x)
- "solution.vs2022.sln" without GlobalSection(SubversionScc) ect and the VisualStudioVersion = ... at the top of the file set to VS2019 version (17.x)
That way the visual studio versions selector opens the right file with the right version.
As said workaround, try it as your own risk.
Thanks for the workaround ibs-ts but having to modify all my solution files doesn;t sit right with me..