ericsink / SQLitePCL.raw

A Portable Class Library (PCL) for low-level (raw) access to SQLite
Apache License 2.0
512 stars 106 forks source link

A problem with AppCenter and VSTO #455

Open KoenJanssensPD opened 2 years ago

KoenJanssensPD commented 2 years ago

see this issue on Appcenter SDK

as suggested in #451, #389, #343,... it did not help to upgrade to 2.0.7-pre20210929171745 did not solve the problem...

bricelam commented 2 years ago

NuGet won't resolve the runtime assets for AnyCPU on .NET Framework. You can tell it to use the current .NET SDK's runtime instead like this:

<PropertyGroup Condition="'$(TargetFramework)' == 'net472'">
    <UseCurrentRuntimeIdentifier>True</UseCurrentRuntimeIdentifier>
</PropertyGroup>

If you're using classic (non-SDK) csproj files, you can just change the platform from AnyCPU:

<PropertyGroup>
  <PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
ericsink commented 2 years ago

@bricelam My goodness these ".NET Framework with AnyCPU" issues just won't go away. I thought I had them resolved with the most recent changes. Is there yet another change I should make?

bricelam commented 2 years ago

Oh, I don't think I actually tried the latest version. 🙂 After updating, it works for me

ericsink commented 2 years ago

@bricelam :

Eric.Sigh(Kind.Relief)

@KoenJanssensPD : Does the 2.0.7 release work as expected for you?

KoenJanssensPD commented 2 years ago

@KoenJanssensPD : Does the 2.0.7 release work as expected for you?

@ericsink , I tried my best to update my test repo, but since I am quite unfamiliar with editing these kind of "meta" (packages, nuget, targetframework, csproj, ...) settings, I did not succeed... :(

Would somebody be able to check my test repo and try to solve it?

viceice commented 2 years ago

2.0.7 thows an error with Microsoft.Data.Sqlite

System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Data.Sqlite.Utilities.ApplicationDataHelper.GetFolderPath(String propertyName)
   at Microsoft.Data.Sqlite.Utilities.ApplicationDataHelper.get_LocalFolderPath()
   at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize()
   at Microsoft.Data.Sqlite.SqliteConnection..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.Data.Sqlite.SqliteConnection..ctor()
   at Microsoft.Data.Sqlite.SqliteFactory.CreateConnection()

Also this also doesn't seem to work on all systems:

<PropertyGroup Condition="'$(TargetFramework)' == 'net472'">
    <UseCurrentRuntimeIdentifier>True</UseCurrentRuntimeIdentifier>
</PropertyGroup>
ericsink commented 2 years ago

To avoid confusion, I'd like to confine this issue to the problem being seen by @KoenJanssensPD the OP. The problem looks specific to VSTO / AppCenter, so I have changed the title of the issue accordingly.

@viceice It looks like your comment above is a separate matter. Please log a separate issue and provide full details of your situation.

ericsink commented 2 years ago

@KoenJanssensPD I've grabbed your test repo and can build it, but I don't have Excel, so I can't actually run it.

One problem I do see is that the project has bundle_sqlite3, but AppCenter has a dep on bundle_green, which means there are two SQLitePCLRaw bundles in play, and that is a no-no. However, I'm not sure that will solve the problem.

The truth is that I've encountered one or two issues before involving SQLitePCLRaw and VSTO, and I don't remember if we ever had success with that case. Maybe we did and I just forgot. Perhaps we can get it figured out this time.

One thing to clarify: Has this ever worked? I think I initially mis-read this issue, thinking that you were saying that it was working and then it broke, but now I'm guessing that you haven't had this working at all.

viceice commented 2 years ago

@ericsink My issue seems to be this: https://github.com/dotnet/efcore/issues/26729

KoenJanssensPD commented 2 years ago

@KoenJanssensPD I've grabbed your test repo and can build it, but I don't have Excel, so I can't actually run it.

One problem I do see is that the project has bundle_sqlite3, but AppCenter has a dep on bundle_green, which means there are two SQLitePCLRaw bundles in play, and that is a no-no. However, I'm not sure that will solve the problem.

The truth is that I've encountered one or two issues before involving SQLitePCLRaw and VSTO, and I don't remember if we ever had success with that case. Maybe we did and I just forgot. Perhaps we can get it figured out this time.

One thing to clarify: Has this ever worked? I think I initially mis-read this issue, thinking that you were saying that it was working and then it broke, but now I'm guessing that you haven't had this working at all.

You are right that this is the first time we try to get AppCenter working with VSTO. We have other types of .net framework applications with AppCenter, so we wanted to get this working for our VSTO projects as well... Probably I have messed up the bundle_green and bundle_sqlite dependencies myself when trying stuff... But even a clean VSTO project where only AppCenter is added gives the same problem...