AnkhSVN icon indicating copy to clipboard operation
AnkhSVN copied to clipboard

Exception in Visual Studio 2022 (version 17.2.0) when opening a solution that uses AnhSvn

Open BrightLight opened this issue 2 years ago • 10 comments

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.

BrightLight avatar May 13 '22 15:05 BrightLight

I am receiving the same error, but I'm able to continue working and even Ankh seems to be working ok.

arsjones avatar May 13 '22 16:05 arsjones

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.

hgbutte avatar May 17 '22 07:05 hgbutte

I rebuilt the package with latest Microsoft.VisualStudio.OLE.Interop package and that seem to solve the issue.

mxtmra avatar May 17 '22 08:05 mxtmra

This appears to be the same issue as https://github.com/AmpScm/AnkhSVN/issues/44

RincewindTVD avatar May 18 '22 22:05 RincewindTVD

After reading #44 I tried the vsix from the MSBuild 121 action and can confirm that I no longer get the exception.

BrightLight avatar May 19 '22 11:05 BrightLight

Yes, after #44 now is working, thanks

Julimuz avatar May 19 '22 17:05 Julimuz

MSBuild 121 action has expired so there's not a solution in this moment. Please, update the VSIX on the Marketplace if possible. Thanks!

agausachs avatar Nov 07 '22 09:11 agausachs

Hi, I have the same problem with VS2022, please fix it.

image image image

eliaocchiuzzi avatar Nov 23 '22 17:11 eliaocchiuzzi

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.

ibs-ts avatar Jan 26 '23 16:01 ibs-ts

Thanks for the workaround ibs-ts but having to modify all my solution files doesn;t sit right with me..

cyrilwallace avatar Feb 23 '23 10:02 cyrilwallace