Reavert / VisualStudioDiscordRPC

Discord rich presence for Visual Studio with support for 2019 and 2022 versions.
https://marketplace.visualstudio.com/publishers/Ryavel
MIT License
74 stars 9 forks source link

"Package did not load correctly" on direct loading some solutions/projects #45

Open AHollowedHunter opened 10 months ago

AHollowedHunter commented 10 months ago

I'm having issues with the extension failing to load when launching certain Solutions/Projects directly from the .sln or .csproj files, but not all solutions exhibit this behaviour.

If I open VS directly and select a solution to open once VS is already running, I don't encounter this issue, so is a workaround for now.

I cannot pinpoint for certain anything specific about the solutions to cause this issue, yesterday I had this problem on a bunch of different solutions and project, and I ended up reinstalling the extension after first clearing my config folder. After a fresh install of the extension, everything was working again on any solution. I updated my settings and continued working fine.

Upon launching a solution today, the same error occurs. Weirdly, other solutions that this issue would happen before I reinstalled won't cause this issue; hence I find it hard to pinpoint if there is something specific about any solutions to trigger this. But...

Windows targets - related or redhearing?

The solution I had the issue with today contains a WinUI 3 project, targetting net6.0-windows. I was looking through issues and in #39 saw they reinstalled the Windows SDK and the problem was gone. I found another solution I had on hand that this error occurs with, and it turns out that has a project targetting net7.0-windows; if someone wants to try and reproduce it was ValveResourceFormat, or possible try creating a new project that builds a Windows application. This might be coincidence though, as I was getting this error before with other project targets.


Windows 11 Pro, 22621.2428 Visual Studio 17.8.0 Preview 5, Community 2022 VisualStudioDiscordRPC 1.6.1

Error Extract:

  <entry>
    <record>385</record>
    <time>2023/10/28 12:11:24.200</time>
    <type>Information</type>
    <source>VisualStudio</source>
    <description>Begin package load [VisualStudioDiscordRPCPackage]</description>
    <guid>{5CD3D640-3D33-45EA-8C5B-6DE981FF9900}</guid>
  </entry>
  <entry>
    <record>386</record>
    <time>2023/10/28 12:11:24.217</time>
    <type>Information</type>
    <source>VisualStudio</source>
    <description>Begin package load [Microsoft.VisualStudio.Shell.Connected.ConnectedUser.ConnectedUserPackage]</description>
    <guid>{7F679D93-2EB6-47C9-85EB-F6AD16902662}</guid>
  </entry>
  <entry>
    <record>387</record>
    <time>2023/10/28 12:11:24.285</time>
    <type>Information</type>
    <source>VisualStudio</source>
    <description>End package load [Microsoft.VisualStudio.Shell.Connected.ConnectedUser.ConnectedUserPackage]</description>
    <guid>{7F679D93-2EB6-47C9-85EB-F6AD16902662}</guid>
  </entry>
  <entry>
    <record>388</record>
    <time>2023/10/28 12:11:24.286</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>SetSite failed for package [VisualStudioDiscordRPCPackage]Source: &apos;Microsoft.VisualStudio.Interop&apos; Description: Value does not fall within the expected range.&#x000D;&#x000A;System.ArgumentException: Value does not fall within the expected range.&#x000D;&#x000A;   at EnvDTE80.DTE2.get_ActiveDocument()&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.Variables.FileNameVariable..ctor(VsObserver vsObserver)&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.Services.VariableService..ctor(VsObserver vsObserver)&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.PackageController.RegisterServices()&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.PackageController.Init()&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.VisualStudioDiscordRPCPackage.&lt;InitializeAsync&gt;d__2.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A;   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#x000D;&#x000A;   at Microsoft.VisualStudio.Shell.AsyncPackage.&lt;&gt;c__DisplayClass21_0.&lt;&lt;Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize&gt;b__1&gt;d.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A;   at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e)&#x000D;&#x000A;   at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)</description>
    <guid>{5CD3D640-3D33-45EA-8C5B-6DE981FF9900}</guid>
    <hr>0x80070057 - E_INVALIDARG</hr>
    <errorinfo></errorinfo>
  </entry>
<!-- NO MORE ENTRIES AFTER THIS -->
Reavert commented 10 months ago

Hi. I see a problem in your error log. Something is wrong with the variable system that appeared in version 1.6.0. The error occurred on the IDE side when the extension requested the currently active document. But I can't figure out why it happened yet. I'm trying to reproduce the bug now.

AHollowedHunter commented 10 months ago

aha. In which case I'll attach my current settings below:

{
  "RichPresenceEnabled": true,
  "Language": "English",
  "LargeIconPlug": "ExtensionIconPlug",
  "SmallIconPlug": "VisualStudioVersionIconPlug",
  "DetailsPlug": "SolutionNameTextPlug",
  "StatePlug": "ProjectNameTextPlug",
  "TimerPlug": "ApplicationScopeTimerPlug",
  "FirstButtonPlug": "GitRepositoryButtonPlug",
  "SecondButtonPlug": "NoneButtonPlug",
  "ApplicationID": "914622396630175855",
  "UpdateTimeout": 1000,
  "Version": "1.6.1",
  "UpdateNotifications": true,
  "TranslationsPath": "Translations/"
}

These were set via the extension settings menu after I reinstalled 1.6.1 yesterday

Reavert commented 10 months ago

Hm.. Everything is fine with the settings here. Then one more question. Have you created any of your own plugs through this menu? image

AHollowedHunter commented 10 months ago

Not currently.

I did use one before reinstalling yesterday, but I had already reset my config to default before that. My current custom_plugs.json is an empty array: [], and settings as above

Reavert commented 10 months ago

Okay. I just made a debugging build. I changed the interface through which the interaction takes place to an older one. Can you please delete the current version of the extension and install this one? VisualStudioDiscordRPC.Dev17.zip

AHollowedHunter commented 10 months ago

I removed the old version, cleared the old config folder, and installed the debug build.

I launched my solution directly and the error came up again. The extension has recreated the config folder in ~\AppData\Local\VisualStudioDiscordRPC, but the folder remains empty. I am unable to edit the settings as the same error popup occurs when attempting to open the extension settings.

  <entry>
    <record>2218</record>
    <time>2023/10/28 14:24:38.726</time>
    <type>Information</type>
    <source>VisualStudio</source>
    <description>Begin package load [VisualStudioDiscordRPCPackage]</description>
    <guid>{5CD3D640-3D33-45EA-8C5B-6DE981FF9900}</guid>
  </entry>
  <entry>
    <record>2219</record>
    <time>2023/10/28 14:24:38.757</time>
    <type>Information</type>
    <source>VisualStudio</source>
    <description>Begin package load [Microsoft.VisualStudio.Shell.Connected.ConnectedUser.ConnectedUserPackage]</description>
    <guid>{7F679D93-2EB6-47C9-85EB-F6AD16902662}</guid>
  </entry>
  <entry>
    <record>2220</record>
    <time>2023/10/28 14:24:38.848</time>
    <type>Information</type>
    <source>VisualStudio</source>
    <description>End package load [NuGetPackage]</description>
    <guid>{5FCC8577-4FEB-4D04-AD72-D6C629B083CC}</guid>
  </entry>
  <entry>
    <record>2221</record>
    <time>2023/10/28 14:24:38.848</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>SetSite failed for package [VisualStudioDiscordRPCPackage]Source: &apos;VisualStudioDiscordRPC.Dev17&apos; Description: Object reference not set to an instance of an object.&#x000D;&#x000A;System.NullReferenceException: Object reference not set to an instance of an object.&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.Services.SettingsService.MigrateFromLegacySettings()&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.Services.SettingsService..ctor()&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.PackageController.RegisterServices()&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.PackageController.Init()&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.VisualStudioDiscordRPCPackage.&lt;InitializeAsync&gt;d__2.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A;   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#x000D;&#x000A;   at Microsoft.VisualStudio.Shell.AsyncPackage.&lt;&gt;c__DisplayClass21_0.&lt;&lt;Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize&gt;b__1&gt;d.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A;   at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e)&#x000D;&#x000A;   at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)</description>
    <guid>{5CD3D640-3D33-45EA-8C5B-6DE981FF9900}</guid>
    <hr>0x80004003 - E_POINTER</hr>
    <errorinfo></errorinfo>
  </entry>

I attempted to open another solution which was working this morning, and it too gives the same error as above.

Finally I tried launching VS without any solution, and the extension errors out then too

Reavert commented 10 months ago

Oh. Sorry. This is another error. Try again with this one VisualStudioDiscordRPC.Dev17.zip

AHollowedHunter commented 10 months ago

Okay, so I cleared the config and installed that newer one.

I directly launched my solution that was erroring. It loaded fine, and my discord activity updated. I closed VS and re-opened the same solution, no error. I closed VS and re-opened the ValveResourceFormat solution, the error occurs again. I closed and tried my solution again, no error. I tried other solutions too, none are erroring.


  <entry>
    <record>388</record>
    <time>2023/10/28 14:43:27.167</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>SetSite failed for package [VisualStudioDiscordRPCPackage]Source: &apos;&apos; Description: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))&#x000D;&#x000A;System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))&#x000D;&#x000A;   at EnvDTE.DTE.get_ActiveDocument()&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.Variables.FileNameVariable..ctor(VsObserver vsObserver)&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.Services.VariableService..ctor(VsObserver vsObserver)&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.PackageController.RegisterServices()&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.PackageController.Init()&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.VisualStudioDiscordRPCPackage.&lt;InitializeAsync&gt;d__2.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A;   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#x000D;&#x000A;   at Microsoft.VisualStudio.Shell.AsyncPackage.&lt;&gt;c__DisplayClass21_0.&lt;&lt;Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize&gt;b__1&gt;d.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A;   at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e)&#x000D;&#x000A;   at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)</description>
    <guid>{5CD3D640-3D33-45EA-8C5B-6DE981FF9900}</guid>
    <hr>0x80070057 - E_INVALIDARG</hr>
    <errorinfo></errorinfo>
  </entry>

I will restart and try again

AHollowedHunter commented 10 months ago

Same situation after restart, only VRF solution will cause the error. All my own solutuions work fine.

I will update my settings and try a few more times

Reavert commented 10 months ago

I will try to clone and run the same solution.

AHollowedHunter commented 10 months ago

I tried changing my settings one-by-one, nothing changed for anything. Still only VRF was causing issues.

I tried another test, I deleted my .vs folder from that solutions root, and upon launch nothing errored, and the extension correctly updated my discord activity!

I checked for a fluke, I deleted the new folder, restored the old: Error. I delete it again, loaded it and no error with a clean .vs folder.

Reavert commented 10 months ago

Hm... It's confusing. I can't even guess why this happened and how it affects the extension.

Reavert commented 10 months ago

For me, the project started correctly and without any errors and correctly displayed activity in Discord

AHollowedHunter commented 10 months ago

For me, the project started correctly and without any errors and correctly displayed activity in Discord

That seems to match what happened for me when I cleared the .vs folder, effectively a fresh clone at that point.

There's a load of binary files in .vs, and I've had weirdness before where the solution is to nuke it. I tried a grep within the affected .vs folder for 'discord' or partial extension guid but nothing coming up.

Reavert commented 10 months ago

Maybe the project got damaged somehow when you were working in it. It affected .vs folder. Then, because of this corruption, the extension could not get the active document or something else. It's hard to tell when an error occurs on the IDE side. I can't even look inside that method to debug.

AHollowedHunter commented 10 months ago

For completeness sake, I uninstalled the debug build and reinstalled the release version, and confirmed everything is loading again and it is.

It's hard to tell when an error occurs on the IDE side. I can't even look inside that method to debug.

Unless you happen to replicate it, I guess this probably is just a weird VS thing rather than a problem with the extension; it works if waiting for a few seconds after launching VS before opening the solution, and only incosistantly with some solutions.

If you want to close this at this point, thats cool; thank you for the help 😄

For anyone else that has this problem; try deleting the .vs folder (make a backup just in case). Note: that will clear all your open tabs etc. so be aware fellow multi-row tab gremlins 🥲

Reavert commented 10 months ago

Okay It's good. I'll leave the Issue open for a few days in case it starts again.

AHollowedHunter commented 10 months ago

Unfortunately had this again just now; again not on all solutions (VRF is fine still). I'll continue to just load VS and wait before loading my solutions for now.

There was also an update for VS (17.8.0 Preview 6), but that didn't affect it at all. I don't have normal installed to test. The fact the .vs folder affects this points towards a VS problem; might be worth keeping an eye out for 17.8 to hit full release in case this problem becomes widespread

Fabita98 commented 7 months ago

Hm.. Everything is fine with the settings here. Then one more question. Have you created any of your own plugs through this menu? image

The same error happened to me after creating a new entry through this prompt, do you know how to solve it? I've already tried to uninstall/reinstall the extension and update VS 22 but nothing has improved yet.

Reavert commented 7 months ago

Hm.. Everything is fine with the settings here. Then one more question. Have you created any of your own plugs through this menu? image

The same error happened to me after creating a new entry through this prompt, do you know how to solve it? I've already tried to uninstall/reinstall the extension and update VS 22 but nothing has improved yet.

Hi! Can you provide your ActivityLog.xml file? Since the error "The package was loaded incorrectly" is a common error that appears when any exception occurs.

Fabita98 commented 7 months ago

Hm.. Everything is fine with the settings here. Then one more question. Have you created any of your own plugs through this menu? image

The same error happened to me after creating a new entry through this prompt, do you know how to solve it? I've already tried to uninstall/reinstall the extension and update VS 22 but nothing has improved yet.

Hi! Can you provide your ActivityLog.xml file? Since the error "The package was loaded incorrectly" is a common error that appears when any exception occurs.

Since xml files are not uploadable, it has been converted to .txt here: ActivityLog.txt

InternalHigh commented 7 months ago

@Reavert Hello! 1.6.5 is broken. I downgrade to 1.6.4 and it just works

It must be https://github.com/Reavert/VisualStudioDiscordRPC/commit/9fcc36a7ded8366c203df5db2ab6728be8ecbf0e

<description>SetSite failed for package [VisualStudioDiscordRPCPackage]Source: &apos;mscorlib&apos; Description: Value cannot be null.&#x000D;&#x000A;Parameter name: s&#x000D;&#x000A;System.ArgumentNullException: Value cannot be null.&#x000D;&#x000A;Parameter name: s&#x000D;&#x000A;   at System.Text.UTF8Encoding.GetByteCount(String chars)&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.Nests.DetailsNest.Update(String data)&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.Nests.Base.BaseDataNest`1.OnPlugUpdatePerformed(TData data)&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.DiscordRpcController.SetPlug[TNest](BasePlug plug)&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.PackageController.ApplySettings()&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.PackageController.Init()&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.VisualStudioDiscordRPCPackage.&lt;InitializeAsync&gt;d__2.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A;   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#x000D;&#x000A;   at Microsoft.VisualStudio.Shell.AsyncPackage.&lt;&gt;c__DisplayClass21_0.&lt;&lt;Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize&gt;b__1&gt;d.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A;   at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e)&#x000D;&#x000A;   at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)</description>

System.ArgumentNullException: Value cannot be null. Parameter name: s at System.Text.UTF8Encoding.GetByteCount(String chars)

Reavert commented 7 months ago

@InternalHigh Hi! Yeah. It's easy to fix But how did you reproduce this? Because I can't :(

InternalHigh commented 7 months ago

@InternalHigh Hi! Yeah. It's easy to fix But how did you reproduce this? Because I can't :(

I think you can reproduce when Details is NoneTextPlug

image

NoneTextPlug returns null in GetData()

Reavert commented 7 months ago

@InternalHigh Hi! Yeah. It's easy to fix But how did you reproduce this? Because I can't :(

I think you can reproduce when Details is NoneTextPlug

image

NoneTextPlug returns null in GetData()

Yes. It actually is. Thanks. There will be a fix soon.

Fabita98 commented 7 months ago

@Reavert Hello! 1.6.5 is broken. I downgrade to 1.6.4 and it just works

It must be 9fcc36a

<description>SetSite failed for package [VisualStudioDiscordRPCPackage]Source: &apos;mscorlib&apos; Description: Value cannot be null.&#x000D;&#x000A;Parameter name: s&#x000D;&#x000A;System.ArgumentNullException: Value cannot be null.&#x000D;&#x000A;Parameter name: s&#x000D;&#x000A;   at System.Text.UTF8Encoding.GetByteCount(String chars)&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.Nests.DetailsNest.Update(String data)&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.Nests.Base.BaseDataNest`1.OnPlugUpdatePerformed(TData data)&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.DiscordRpcController.SetPlug[TNest](BasePlug plug)&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.PackageController.ApplySettings()&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.PackageController.Init()&#x000D;&#x000A;   at VisualStudioDiscordRPC.Shared.VisualStudioDiscordRPCPackage.&lt;InitializeAsync&gt;d__2.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A;   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#x000D;&#x000A;   at Microsoft.VisualStudio.Shell.AsyncPackage.&lt;&gt;c__DisplayClass21_0.&lt;&lt;Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize&gt;b__1&gt;d.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A;   at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e)&#x000D;&#x000A;   at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)</description>

System.ArgumentNullException: Value cannot be null. Parameter name: s at System.Text.UTF8Encoding.GetByteCount(String chars)

So the temporary solution is to use the 1.6.4 version at least until 1.6.5 will be fixed? Because before the change through that prompt, everything worked fine.

Reavert commented 7 months ago

@Fabita98 This bug is fixed in 1.6.6 version. You can update the extension and everything will be fine.

Biglulux commented 6 months ago

This extension was working fine for a while, but on updating to VS 17.9.1 I started getting this error.

VS version: 2022 Community 17.9.1 Extension version: 1.6.5

Activity log: ActivityLog.txt

Reavert commented 6 months ago

@Biglulux You're using the old version. The current version is 1.6.6. This bug has been fixed in the latest version

Biglulux commented 6 months ago

Great, just updated and it worked. For some reason it wasn't automatically updating. Thanks.