I'm trying to read in the connection properties from the DataConnection property of a CIMFeatureLayer's FeatureTable property, and use those properties to instantiate an ArcGIS.Core.Data.Database object (using the constructor that takes a DatabaseConnectionProperties object). This is a SQLServer connection that was created in the Catalog, and whose layer(s) were added to the Map represented in a CIMMapDocument.
I have done this successfully with an Oracle connection, but I'm having trouble getting it to work with a SQLServer connection. I am just parsing the WorkspaceConnectionString from the CIMStandardDataConnection and using those key-value pairs (AuthenticationMode, Branch, Database, Instance, etc.) to create a DatabaseConnectionProperties object.
The issue with a SQLServer connection happens when I try to instantiate a Database object using those properties. The constructor call causes the database configuration dialog to pop up in the the Arc Pro GUI - which is expected, given that the password is not saved unencrypted in the CIM, and it will need to be provided. However, when I enter the password, I get an indefinite hang. If I turn on the most granular exception-handling in my debugger, I get the COM exception: 'Exception from HRESULT: 0x80050199'. Following that exception is the GeodatabaseEnterpriseException, : 'Lost connection to underlying DBMS. Reason: Failure to access the DBMS server'.
I'm not sure how to proceed. There could be something wrong in the way I'm creating the DatabaseConnectionProperties, but the fact that the same method is working for an Oracle connection makes me wonder if the problem lies elsewhere.