Alpaca .Net SDK Unity Integration issues and Solutions: C#
See original GitHub issueStep 1: Access the official Alpaca SDK page to find the NuGet Package Link here: https://alpaca.markets/docs/api-documentation/client-sdk/ #SupportImageAttached1:
Step 2: Download the NuGet Package version (5.0.6) from here: https://www.nuget.org/packages/Alpaca.Markets/ #SupportImageAttached2:
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:
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:
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:
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:
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:
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:
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:
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:
-END (Sorry for any typos found…)
Issue Analytics
- State:
- Created 2 years ago
- Comments:10
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.
OK. I see 2 main problems in the errors list:
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 theNewtonsoft.Json
and update it with the newer one.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:
dotnet
command that will target .NET Standard 2.0Alpaca.Markets
NuGet package (and theAlpaca.Markets.Extensions
package if needed) into this project.dll
files from the output folder except the project name.dll
file and place them into the Unity Assets folderI 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.