I have added to my add-in a nuget package for Npgsql.
I am working with Pro 2.6.2
The latest verison i.e.
NuGet\Install-Package Npgsql -Version 6.0.7
when I get to the code that starts to try to connect to my DB, I get thrown the error: Exception thrown: 'System.IO.FileNotFoundException' in Npgsql.dll.
Can you please look into this.
It may have something to do with this error - that it can't find the correct version assembly for System.Runtime.CompilerServices.Unsafe, I believe the one installed by default is version 6:
System.AggregateException
HResult=0x80131500
Message=A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread.
Source=mscorlib
StackTrace:
at System.Threading.Tasks.TaskExceptionHolder.Finalize()
Inner Exception 1:
FileNotFoundException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
As an update to this - it just looks like it doesn't work with ESRI add-in projects. I tried many different versions of Npgsql and all failed. Here are the results for the various versions:
I really need help on this please. Anyone from ESRI?
Hi,
I think you need earlier version of Npqsql (5.0.15 or earlier) because your version needs .Net 6.0 or higher.
If I remember ArcGIS Pro 2.6 uses .NET Framework 4.8
Or you need to migrate to ArcGIS Pro 3.0 which uses .Net 6.0
https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic1.html
I'm kind of locked into the version I'm using because of end clients - but I tried the version you suggested - 5.0.15, and it failed in a similar way.
This is proving so exasperating. I can't even get the ODBC drivers to work either as work around the Npgsql library.
Try to check Npqsql (5.0.15) reference properties. "Copy Local" property must be set to "True".
"Copy Local" is the default when you install. But thanks.
If you just reinstalled Npqsql from 6.0.7 to 5.0.15, then you need to cleanup packages.config.
After reinstall you would get something like this:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="6.0.0" targetFramework="net48" />
<package id="Microsoft.Bcl.HashCode" version="1.1.1" targetFramework="net48" />
<package id="Npgsql" version="5.0.15" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Collections.Immutable" version="6.0.0" targetFramework="net48" />
<package id="System.Diagnostics.DiagnosticSource" version="6.0.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.4" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" />
<package id="System.Text.Encodings.Web" version="6.0.0" targetFramework="net48" />
<package id="System.Text.Json" version="6.0.0" targetFramework="net48" />
<package id="System.Threading.Channels" version="6.0.0" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
</packages>
If you cleanup packages.config and install Npqsql 5.0.15 from scratch you would get:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="1.0.0" targetFramework="net48" />
<package id="Npgsql" version="5.0.15" targetFramework="net48" />
<package id="System.Buffers" version="4.5.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.3" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.6.0" targetFramework="net48" />
<package id="System.Text.Encodings.Web" version="4.6.0" targetFramework="net48" />
<package id="System.Text.Json" version="4.6.0" targetFramework="net48" />
<package id="System.Threading.Channels" version="4.7.0" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
</packages>
After reinstall your packages.config keeps libraries which are incompatible with .Net 4.8.
Packages seem to right. I cleaned the cache - but no difference.
Update
I have tried version 2.9 of Pro and still the same issues.
I then tried version 3.0.2 - and it works fine. Not massively useful to me but at least its something.
@Wolf @CharlesMacleod do you have any ideas guys why the postgres api does not work in version 2.x of Pro addins?