C
C#2y ago
Puck

❔ update-package : Failed to add reference to 'xyz'. Error HRESULT E_FAIL has been returned

So I don't really know what happened. Turned my pc on, opened a project I created 2 days ago. My pacakges.config file was missing and was like ok weird. Made nuget recreate it and realized my references were gone so forced a reinstall through nuget. Now, for whatever reason I keep getting failed HRESULTS. It isn't specific to discord.net, it happens to random packages the more I retry, it just picks a random package to error. I have tried to delete the nuget cache, nuget.config file and I have also ran the command that is meant to fix the problem gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll but no luck. I have both VS 2022 and 2017, both of them seem to return the same exact issue now. I'm not sure what happened but I think a cache is corrupt? I just don't know which one...
I have tried to create a new project with .net framework console, tried different versions ranging from 4.6-4.8 and still the issue persists. I'd only have to assume it would be the same for .net core.
Here is the error I get
update-package : Failed to add reference to 'Discord.Net.Core'.
Error HRESULT E_FAIL has been returned from a call to a COM component.
At line:1 char:1
+ update-package -reinstall
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Update-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand

update-package : Failed to add reference to 'Discord.Net.Core'.
Error HRESULT E_FAIL has been returned from a call to a COM component.
At line:1 char:1
+ update-package -reinstall
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Update-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand

Would love to know if someone has managed to fix this before because this is the first time It has happened to me. Very frustrating 😦 It doesn't seem to matter what VS I use, be it 2017 or 2022, it gives the same issue even if I create a new project on both VS's separately.
2 Replies
jcotton42
jcotton422y ago
packages.config? that's only for pre-SDK projects, which only exist for .NET Framework, and I'd hope you wouldn't be using Framework for a Discord bot (or anything at all really) you should be using .NET 7, which uses SDK projects, which use PackageReference the Discord.Net docs specifically recommend .NET 6 or later
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server