Using the TPL Dataflow library
Using the TPL Dataflow library
24 Apr 2020, 10:26
Hi All,
I'm hoping someone can help me figure this out...
I'm trying to get the use of the System.Threading.Tasks.Dataflow library / namespace for a cBot, but am running into issues. I've tried a couple of ways:
1) In cTrader:
Method: Manage References -> .NET Framework -> Microsoft.Internal.Tasks.Dataflow
Error: E.g. 'ActionBlock<>' is inaccessible due to its protection level
2) In Visual Studio 2019:
(i) Method: NuGet Package Manager -> System.Threading.Tasks.Dataflow
Error: You are trying to install this package into a project that targets '.NETFramework,Version=v4.0,Profile=Client', but the package does not contain any assembly references or content files that are compatible with that framework.
(ii) Method: Add References -> From file: System.Threading.Tasks.Dataflow.dll (various versions)
Error: E.g. The type 'Action<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=...'
Is there a way to get this working? I'd really appreciate any support.
Thanks,
John
Replies
JohnK
24 Apr 2020, 11:10
RE:
PanagiotisCharalampous said:
Hi JohnK,
Can we also have the cBot source code to reproduce this issue?
Best Regards,
Panagiotis
Hi Panagiotis,
Thanks for the reply. There is "no code" as yet - I've just created a new cBot & tried to add the reference.
To see if the reference works, I've tried to type e.g. var actionBlock = new ActionBlock<int>(n => Print(n));
@JohnK
PanagiotisCharalampous
24 Apr 2020, 11:16
Hi JohnK,
Did you re-target your project to .Net Framework 4.5?
Best Regards,
Panagiotis
@PanagiotisCharalampous
JohnK
24 Apr 2020, 11:52
RE:
So even with re-targeting, there are still issues...
When adding the reference through the cTrader platform & re-targeting to 4.5
-> Error: ...is inaccessible due to its protection level
When adding it in VS with NuGet package installer after re-targeting to 4.5:
-> Error: ...is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=...
@JohnK
PanagiotisCharalampous
24 Apr 2020, 12:11
Hi JohnK,
You need to post the complete cBot code and screenshots of the steps you are taking to reproduce these issues as I cannot reproduce them. In any case, cTrader Automate does not support .Net Framework 4.5 at the moment. If I manage to reproduce the issue and provide a workaround, I will let you know.
Best Regards,
Panagiotis
@PanagiotisCharalampous
JohnK
24 Apr 2020, 12:50
RE:
Hi Panagiotis,
Thanks for the info! Based on that, I've installed the library version that supports 4.0 & haven't needed to re-target the project.
All seems to work as expected at first glance. Seems perhaps I was running into compatibility issues between what cTrader & TPL Dataflow support.
If anyone else is looking for the library version supporting .NET 4, you can get it from NuGet with:
PM> Install-Package HomeLab.Tpl.DataFlow -Version 4.0.0
@JohnK
PanagiotisCharalampous
24 Apr 2020, 10:50
Hi JohnK,
Can we also have the cBot source code to reproduce this issue?
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous