jeffdapaz / VisualChatGPTStudio

Add chatGPT functionalities directly on Visual Studio
https://marketplace.visualstudio.com/items?itemName=jefferson-pires.VisualChatGPTStudio
MIT License
210 stars 51 forks source link

Does not work on VS 2022 17.9 Preview on ARM64 #62

Closed ktos closed 8 months ago

ktos commented 8 months ago

Hi, I'm using VS 2022 17.9 Preview 2 (which I believe is not the problem) on ARM64 (which I believe is the problem) and I am getting the message from VS saying the Visual chatGPT Studio failed when loading.

In the ActivityLog.xml, there is a FileNotFoundException:

SetSite failed for package [VisuallChatGPTStudioPackage]Source: 'mscorlib' Description: Exception has been thrown by the target of an invocation.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SQLite, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. The system cannot find the file specified.
   at JeffPires.VisualChatGPTStudio.Utils.ChatRepository.CreateDataBase()
   at JeffPires.VisualChatGPTStudio.ToolWindows.Turbo.TerminalWindowTurboControl..ctor() in C:\TFS_GitHub\jeffdapaz\VisualChatGPTStudio\VisualChatGPTStudioShared\ToolWindows\Turbo\TerminalWindowTurboControl.xaml.cs:line 35
   at JeffPires.VisualChatGPTStudio.ToolWindows.Turbo.TerminalWindowTurbo..ctor() in C:\TFS_GitHub\jeffdapaz\VisualChatGPTStudio\VisualChatGPTStudioShared\ToolWindows\Turbo\TerminalWindowTurbo.cs:line 31
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at Microsoft.VisualStudio.Shell.Package.InstantiateToolWindow(Type toolWindowType, Object context)
   at Microsoft.VisualStudio.Shell.Package.<>c__DisplayClass87_0.<CreateToolWindow>g__CreateToolWindowWorker|1()
   at Microsoft.VisualStudio.Shell.Package.CreateToolWindow(Type toolWindowType, Int32 id, UInt32 flags, Object context, Guid persistenceGuid)
   at Microsoft.VisualStudio.Shell.Package.CreateToolWindow(Type toolWindowType, Int32 id, ProvideToolWindowAttribute tool, Object context)
   at Microsoft.VisualStudio.Shell.AsyncPackage.<CreateToolWindowAsync>d__38.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Shell.AsyncPackage.<>c__DisplayClass47_0.<<FindToolWindowAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Shell.ToolWindowCollection.ToolWindowListener.<>c__DisplayClass1_0.<<-ctor>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.AwaitExtensions.ExecuteContinuationSynchronouslyAwaiter`1.GetResult()
   at Microsoft.VisualStudio.Threading.AsyncLazy`1.<>c__DisplayClass16_0.<<GetValueAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Shell.AsyncPackage.<FindToolWindowAsync>d__47.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Shell.AsyncPackage.<FindToolWindowAsync>d__45.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at JeffPires.VisualChatGPTStudio.Commands.TerminalWindowTurboCommand.<InitializeToolWindowAsync>d__12.MoveNext() in C:\TFS_GitHub\jeffdapaz\VisualChatGPTStudio\VisualChatGPTStudioShared\Commands\TerminalWindowTurboCommand.cs:line 101
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at JeffPires.VisualChatGPTStudio.Commands.TerminalWindowTurboCommand.<InitializeAsync>d__10.MoveNext() in C:\TFS_GitHub\jeffdapaz\VisualChatGPTStudio\VisualChatGPTStudioShared\Commands\TerminalWindowTurboCommand.cs:line 78
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at JeffPires.VisualChatGPTStudio.VisuallChatGPTStudioPackage.<InitializeAsync>d__8.MoveNext() in C:\TFS_GitHub\jeffdapaz\VisualChatGPTStudio\VisualChatGPTStudioShared\VisuallChatGPTStudioPackage.cs:line 64
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Shell.AsyncPackage.<>c__DisplayClass21_0.<<Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e)
   at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SQLite, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Data.SQLite, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139'
   at JeffPires.VisualChatGPTStudio.Utils.ChatRepository.CreateDataBase()
   at JeffPires.VisualChatGPTStudio.ToolWindows.Turbo.TerminalWindowTurboControl..ctor() in C:\TFS_GitHub\jeffdapaz\VisualChatGPTStudio\VisualChatGPTStudioShared\ToolWindows\Turbo\TerminalWindowTurboControl.xaml.cs:line 35
   at JeffPires.VisualChatGPTStudio.ToolWindows.Turbo.TerminalWindowTurbo..ctor() in C:\TFS_GitHub\jeffdapaz\VisualChatGPTStudio\VisualChatGPTStudioShared\ToolWindows\Turbo\TerminalWindowTurbo.cs:line 31

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Because it is saying that Could not load file or assembly 'System.Data.SQLite, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. The system cannot find the file specified. the problem is with System.Data.SQLite, I think I know where the problem may be: System.Data.SQLite is not providing ARM64 version of the sqlite .dll library at all, only x86 and x64 versions are there.

I checked out the .csproj file of VisualChatGPT, and there is only a reference to "System.Data.SQLite.x64". Yet, the vsixmanifest is advertising arm64 support, so it was shown in my Extension Manager.

I had a same situation when preparing an ARM64 version for a Flow.Launcher, and there is a package called Microsoft.Data.Sqlite, which is source-compatible with System.Data.SQLite, and based on SQLiteRawPCL, which means there are native sqlite libraries for everything under the sun – however, I do not know how to pack native (arch-dependent) dependencies in a VSIX extension, never worked with that.

jeffdapaz commented 8 months ago

Hi @ktos,

At first when I made the extension available, some people requested that the extension be compatible with the ARM version of VS. I don't have access to an ARM computer, but I made the necessary changes to the extension and then they confirmed that it was now possible to use it on VS ARM.

However, a few months ago I added the SQLite library to be able to store chats from the Turbo window. But as I can't test on a VS ARM, this issue ended up going unnoticed to me.

I remember that at the beginning I tried to use the Microsoft.Data.Sqlite library, but I had problems, however I managed to make it work with System.Data.SQLite.

I'll do some research and testing and let you know something. However, I can't test it myself as I mentioned, so I may ask you to validate it.

jeffdapaz commented 8 months ago

I tried again to use Microsoft.Data.Sqlite instead of System.Data.SQLite but I continued to have problems that I couldn't solve.

So I did some research and found the sqlite-net-pcl library as an alternative, which claims to be cross-platform. I hope this solves the problem.

I generated a release with this change. Can you get it here, install and tell me later if worked? If so, I will publish on the marketplace.

Now if it doesn't solve, I don't see any other alternative at the moment than checking the possibility of detecting via code if the extension is running on an ARM machine, and if so, disabling the chat history. This way, at least it will be possible to use the chat.

Or store the history in a .json file, but depending on the number of messages and chats, performance may end up degrading.

ktos commented 8 months ago

Wow, it was so fast! I had no time to test it out until today.

First I got an error:

Could not open database file: C:\Users\ktos\AppData\Local\Visual chatGPT Studio\VisualChatGptStudio.db (CannotOpen)

But when I have created a folder %LOCALAPPDATA%\Visual chatGPT Studio, the .db file and .json files were properly created inside it. I've added my API key and it seems that everything is working for me right now, I've tested generating some things with "turbo" and regular windows, and history of the chats is also working.

jeffdapaz commented 8 months ago

@ktos, great!

I will fix the folder issue and release this version through marketplace.

Thanks!

jeffdapaz commented 8 months ago

New release published 🙂