question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Alpaca .Net SDK Unity Integration issues and Solutions: C#

See original GitHub issue

Step 1: Access the official Alpaca SDK page to find the NuGet Package Link here: https://alpaca.markets/docs/api-documentation/client-sdk/ #SupportImageAttached1:

AlpacaHelp1


Step 2: Download the NuGet Package version (5.0.6) from here: https://www.nuget.org/packages/Alpaca.Markets/ #SupportImageAttached2:

AlpacaHelp2


This next step assumes you a basic knowledge of installing and using the Unity Engine environment. I’m using Unity version 2020.3.15f2 in this example, but any version 2019 or higher should work. Step 3: Copy the downloaded Package and paste it into a new Unity project’s “Asset’s folder” directory. #SupportImageAttached3:

AlpacaHelp3


Step 4: Notice the NuGet package name at this step: (alpaca.markets.5.0.6.nupkg) I’ll change this name in the following step in order to access the package content. #SupportImageAttached4:

AlpacaHelp4


Step 5: In this step, I changed the downloaded package name by only removing the appended string (.nupkg) replacing it with (.zip ). The package file can now be unzipped, and we can now access the Highlighted content inside: #SupportImageAttached5:

AlpacaHelp5


Step 6: Now inside the Unity Engines inspector, we immediately have the following errors:

Multiple precompiled assemblies with the same name Alpaca.Markets.dll included or the current platform. Only one assembly with the same name is allowed per platform. (Assets/lib/net5.0/Alpaca.Markets.dll)

In the following step, I attempt to identify the duplicate Alpaca.Markets.dll’s : #SupportImageAttached6:

AlpacaHelp6

Step 7: Now after entering the unzipped content folder named “Lib” I noticed (4) additional folders named: {net5.0, net461, netstandard2.0, netstandard2.1}. Each folder containing its own Alpaca.Markets.dll and XML file. In the following step, I attempt to randomly remove (3) of the folders containing what appear to be duplicate Alpaca.Markets.dll and XML files: #SupportImageAttached7:

AlpacaHelp7


The (3) content folders I randomly selected for deletion are: {net5.0, net461, and netstandard2.1} Step 8: Now that I’ve successfully delete (3) of the folders containing the duplicate Alpaca.Markets.dll and XML files, The Unity console presented me with the following new error:

Assembly 'Assets/lib/netstandard2.0/Alpaca.Markets.dll' will not be loaded due to errors:
Unable to resolve reference 'System.Threading.Tasks.Extensions'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Alpaca.Markets references strong named Newtonsoft.Json Assembly references: 13.0.0.0 Found in project: 12.0.0.0.
Assembly Version Validation can be disabled in Player Settings "Assembly Version Validation"
Unable to resolve reference 'Polly'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Unable to resolve reference 'WebSocket4Net'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Unable to resolve reference 'SuperSocket.ClientEngine'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.

#SupportImageAttached8:

AlpacaHelp8


Step 9: At this stage, if I attempt to create a new C# script in Unity called “AlpacaExample.cs”, as you can see in the attached image, I’m able to access the Alpaca namespaces without script compile errors being thrown. However… in the following step… #SupportImageAttached9: AlpacaHelp9


Step 10 FinalStep: Back in the Unity inspector, however; I’m provided the following build error: Assembly ‘Assets/lib/netstandard2.0/Alpaca.Markets.dll’ will not be loaded due to errors:

Unable to resolve reference 'System.Threading.Tasks.Extensions'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Alpaca.Markets references strong named Newtonsoft.Json Assembly references: 13.0.0.0 Found in project: 12.0.0.0.
Assembly Version Validation can be disabled in Player Settings "Assembly Version Validation"
Unable to resolve reference 'Polly'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Unable to resolve reference 'WebSocket4Net'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Unable to resolve reference 'SuperSocket.ClientEngine'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.

And this is where I’m stuck. Thanks for any help one can provide. #SupportImageAttached10:

AlpacaHelp10

-END (Sorry for any typos found…)

Alpaca SDK Unity Integration issues.pdf

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
OlegRacommented, Aug 21, 2021

Please, try to add conent of one of these files into your Assets folder:

I recommend you to start from 5.1.0 version - it has less 3rd party dependencies but 5.0.6 should also works fine.

Please, inform me about results. If this approach will work fine I’ll add the CI/CD step for creating such .zip archive for each SDK version and publish it here attached to the GitHub release.

2reactions
OlegRacommented, Aug 21, 2021

OK. I see 2 main problems in the errors list:

  • The Newtonsoft.Json assembly version (13.0) used by the Alpaca SDK is greater than the version 12.0 used by your Unity project (or any other dependency in this project). It’s not a good idea to downgrade the dependency version in SDK but instead, it would be better to find out the code in your Unity project that uses an old version of the Newtonsoft.Json and update it with the newer one.
  • The System.Threading.Tasks.Extensions, Polly, WebSocket4Net, and `` are not part of NuGet package itself because they are parts of dependent assemblies. There are some ways for obtaining them and I’ll explain the simplest one soon.

I suggest trying the NuGetForUnity tool for importing the Alpaca SDK. It solves a lot of issues related to versions incompatibility and dependencies (even transitive) management. But if you prefer to do it manually use this approach for obtaining the full list of Alpaca SDK binaries with all dependencies:

  1. Create the .NET library project in the VS or using the dotnet command that will target .NET Standard 2.0
  2. Add the Alpaca.Markets NuGet package (and the Alpaca.Markets.Extensions package if needed) into this project
  3. Build the project and get all .dll files from the output folder except the project name .dll file and place them into the Unity Assets folder

I will do these steps later today and attach the results to this issue for you. It will not solve the problem with the Newtonsoft.Json versions mismatch but you will have a full list of dependent assemblies.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Alpaca & Unity Game Engine
I would love to get the Alpaca .Net SDK to work in Unity Game Engine. Has anyone work on this and found a...
Read more >
Issues · alpacahq/alpaca-trade-api-csharp
C# SDK for Alpaca Trade API https://docs.alpaca.markets/ - Issues ... Prepare C#/.NET based step-by-step tutorial ... [BUG]: solution not compiling.
Read more >
NET SDK for Alpaca Markets API
Create a new console application in a new, empty folder by running dotnet new console . Add a reference for Alpaca .NET SDK...
Read more >
Untitled
Net SDK Unity Integration issues and Solutions : C# #364 Getting Started Alpaca Docs Getting Started Alpaca Docs alpaca-trade-api-csharp/README.md at develop ...
Read more >
Visual Studio Code Intellisense doesn't work with Unity 2018
Hello! I have this problem only with Unity 2018.2.0f2. I'm working on other projects in Unity 2017.4.5f1 and the problem does not exist ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found