SQLitePCL.raw icon indicating copy to clipboard operation
SQLitePCL.raw copied to clipboard

A problem with AppCenter and VSTO

Open KoenJanssensPD opened this issue 4 years ago • 10 comments

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...

KoenJanssensPD avatar Oct 12 '21 14:10 KoenJanssensPD

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>

bricelam avatar Nov 17 '21 20:11 bricelam

@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?

ericsink avatar Nov 17 '21 21:11 ericsink

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

bricelam avatar Nov 17 '21 22:11 bricelam

@bricelam :

Eric.Sigh(Kind.Relief)

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

ericsink avatar Nov 18 '21 01:11 ericsink

@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?

KoenJanssensPD avatar Nov 18 '21 11:11 KoenJanssensPD

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>

viceice avatar Nov 18 '21 13:11 viceice

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 avatar Nov 18 '21 15:11 ericsink

@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.

ericsink avatar Nov 18 '21 15:11 ericsink

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

viceice avatar Nov 18 '21 16:11 viceice

@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...

KoenJanssensPD avatar Nov 18 '21 16:11 KoenJanssensPD