<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Revit 2022 Environment Preventing SSL handshake with PostgreSQL in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2022-environment-preventing-ssl-handshake-with-postgresql/m-p/10877521#M26062</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6327265"&gt;@murillo.rocha&lt;/a&gt;&amp;nbsp;I was able to resolve this after the information supplied on the github I had listed.&amp;nbsp; The real issue was DLL hell just like always. The NpgSQL was trying to rely on different versions of references that was loading with Revit. I had to implement an Assembly Resolver to make sure that when the call was coming from my app that the correct references and versions will being loaded.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I did update the GitHub link with my solution, here is a excerpt from it for convenience.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/npgsql/npgsql/issues/3718#issuecomment-897124429" target="_blank" rel="noopener"&gt;https://github.com/npgsql/npgsql/issues/3718#issuecomment-897124429&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public Result OnStartup(UIControlledApplication application)
{
    AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
    return Result.Succeeded;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
    string filename = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "References");
	if(args.Name.Contains("Dapper"))
	{
		filename = Path.Combine(filename, "Dapper.dll");
		if(File.Exists(filename))
		{
			return Assembly.LoadFrom(filename);
		}
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jan 2022 16:17:07 GMT</pubDate>
    <dc:creator>Sean_Page</dc:creator>
    <dc:date>2022-01-13T16:17:07Z</dc:date>
    <item>
      <title>Revit 2022 Environment Preventing SSL handshake with PostgreSQL</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2022-environment-preventing-ssl-handshake-with-postgresql/m-p/10304990#M26060</link>
      <description>&lt;P&gt;I am trying to connect an Azure PostgreSQL DB to Revit via the API and I am running into a very frustrating situation and was hoping someone may have the experience I need to at least know why its failing so I can try to resolve it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have successfully used MySQL and MSSQL in the past without any issues, but for some reason within the Revit context I am getting and SSL error. I know this may not be a direct Revit API question, BUT a desktop application with the EXACT same executing code works flawlessly. So, this make me think there is something (maybe a reference) that is got me caught up here and that is why I am grasping here a bit hoping to get lucky.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code is very straight forward at this point just to test the connection.&lt;/P&gt;&lt;P&gt;1. External Application with a single button that using an external command to call another dll (separated them for multi app support).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace RDG_Revit_2022.Testing
{
	[Transaction(TransactionMode.Manual)]
	class Test : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			UIApplication uiapp = commandData.Application;
			Document doc = uiapp.ActiveUIDocument.Document;
			//This is the external reference call
			pgRDG.Connection.Testing();
			return Result.Succeeded;
		}
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Here is the code within the Testing() method&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using System;
using System.Windows;
using Npgsql;

namespace pgRDG
{
	public class Connection
    {
        public static void Testing()
		{
			string ConnString = "Server=name.postgres.database.azure.com;Database=dbName;Port=5432;User Id=Username;Password=Password;Trust Server Certificate=true;Ssl Mode=Require";
			using(NpgsqlConnection conn = new NpgsqlConnection(ConnString))
			{
				try
				{
					conn.Open();
					NpgsqlCommand cmd = new NpgsqlCommand("SELECT * FROM table", conn);
					NpgsqlDataReader reader = cmd.ExecuteReader();
					while(reader.Read())
					{
						MessageBox.Show(reader.GetString(reader.GetOrdinal("command")));
					}
				}
				catch(Exception ex)
				{
					MessageBox.Show(ex.ToString());
				}
			}
		}
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. When I run the code I receive this error message.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="SSL Handshake.PNG" style="width: 945px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/917524i286366EE46A2A170/image-size/large?v=v2&amp;amp;px=999" role="button" title="SSL Handshake.PNG" alt="SSL Handshake.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, if I run that code in a desktop app it executes without any errors which is why I am posting here wondering if anyone could give me any hints as to what within the Revit environment may be causing this issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also submitted a GitHub request for reference:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/npgsql/npgsql/issues/3718" target="_blank"&gt;Specified SSL Protocol Type is not Valid · Issue #3718 · npgsql/npgsql (github.com)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 10:58:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-2022-environment-preventing-ssl-handshake-with-postgresql/m-p/10304990#M26060</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2021-05-11T10:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: Revit 2022 Environment Preventing SSL handshake with PostgreSQL</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2022-environment-preventing-ssl-handshake-with-postgresql/m-p/10876861#M26061</link>
      <description>&lt;P&gt;I'm having the same problem. &lt;SPAN&gt;I'm waiting for a solution too.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 11:57:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-2022-environment-preventing-ssl-handshake-with-postgresql/m-p/10876861#M26061</guid>
      <dc:creator>murillo.rocha</dc:creator>
      <dc:date>2022-01-13T11:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: Revit 2022 Environment Preventing SSL handshake with PostgreSQL</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2022-environment-preventing-ssl-handshake-with-postgresql/m-p/10877521#M26062</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6327265"&gt;@murillo.rocha&lt;/a&gt;&amp;nbsp;I was able to resolve this after the information supplied on the github I had listed.&amp;nbsp; The real issue was DLL hell just like always. The NpgSQL was trying to rely on different versions of references that was loading with Revit. I had to implement an Assembly Resolver to make sure that when the call was coming from my app that the correct references and versions will being loaded.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I did update the GitHub link with my solution, here is a excerpt from it for convenience.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/npgsql/npgsql/issues/3718#issuecomment-897124429" target="_blank" rel="noopener"&gt;https://github.com/npgsql/npgsql/issues/3718#issuecomment-897124429&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public Result OnStartup(UIControlledApplication application)
{
    AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
    return Result.Succeeded;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
    string filename = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "References");
	if(args.Name.Contains("Dapper"))
	{
		filename = Path.Combine(filename, "Dapper.dll");
		if(File.Exists(filename))
		{
			return Assembly.LoadFrom(filename);
		}
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 16:17:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-2022-environment-preventing-ssl-handshake-with-postgresql/m-p/10877521#M26062</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2022-01-13T16:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Revit 2022 Environment Preventing SSL handshake with PostgreSQL</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2022-environment-preventing-ssl-handshake-with-postgresql/m-p/10879951#M26063</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3064449"&gt;@Sean_Page&lt;/a&gt;!! I made it work here by changing&amp;nbsp;&lt;SPAN&gt;NpgSQL&amp;nbsp;&lt;/SPAN&gt;version 6.0 to version 3.0, but your solution is much more practical!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jan 2022 14:46:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-2022-environment-preventing-ssl-handshake-with-postgresql/m-p/10879951#M26063</guid>
      <dc:creator>murillo.rocha</dc:creator>
      <dc:date>2022-01-14T14:46:38Z</dc:date>
    </item>
  </channel>
</rss>

