Legacy Build with Visual Studio 2019 fails with error "No cTrader or cAlgo was found with version 1.20 or higher"

Created at 23 Nov 2024, 22:09
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
MA

martins

Joined 22.10.2019

Legacy Build with Visual Studio 2019 fails with error "No cTrader or cAlgo was found with version 1.20 or higher"
23 Nov 2024, 22:09


Legacy builds were ok earlier today, cTrader 4.9.2 was running, after stop & restart it had upgraded to 5.0.46 and since then Legacy Robots & Indicators won't build in VS 2019. 
There's a 12 in the Line column of the errors window but no file name, can't see any obvious link with line 12 of the .cs or .sln or .cproj files.

…/Documents/cAlgo/API/cAlgo.API.dll is new, last modified 21/11/2024 so possibly that's the direct cause.  

How to proceed?   

Thanks

 

Update: solved by uninstall/reinstall. Don't think it was the dll since it's still 21/11.
 
Can you explain exactly how VS build normally finds the cTrader/cAlgo part that was missing? 
 


@martins
Replies

firemyst
24 Nov 2024, 09:40

Open up the Visual Studio “.csproj” file.

You'll see a section similar to:

<ItemGroup>
   <PackageReference Include="cTrader.Automate" Version="1.*" />
 </ItemGroup>

Or maybe even:

 <ItemGroup>
   <PackageReference Include="cTrader.Automate" Version="*" />
 </ItemGroup>

In previous incarnations, I think the version was hard coded like such:

 <ItemGroup>
   <PackageReference Include="cTrader.Automate" Version="1.1" />
 </ItemGroup>


@firemyst

martins
24 Nov 2024, 14:17 ( Updated at: 25 Nov 2024, 06:26 )

RE: Legacy Build with Visual Studio 2019 fails with error "No cTrader or cAlgo was found with version 1.20 or higher"

firemyst said: 

Open up the Visual Studio “.csproj” file.

You'll see a section similar to:

<ItemGroup>
   <PackageReference Include="cTrader.Automate" Version="1.*" />
 </ItemGroup>

Or maybe even:

 <ItemGroup>
   <PackageReference Include="cTrader.Automate" Version="*" />
 </ItemGroup>

In previous incarnations, I think the version was hard coded like such:

 <ItemGroup>
   <PackageReference Include="cTrader.Automate" Version="1.1" />
 </ItemGroup>

Thanks for the suggestion, might that be for 2022 projects using Automate rather 2019 with cAlgo.API?


An example of VS 2022 project I have is short and contains the 1.* Automate reference:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
 <PropertyGroup>
   <TargetFramework>net472</TargetFramework>
 </PropertyGroup>
 <ItemGroup>
   <PackageReference Include="cTrader.Automate" Version="1.*" />
 </ItemGroup>
</Project>

whereas the 2019 version of the same indicator is much longer (similar for other legacy stuff) containing a dll reference to cAlgo.API, Version=1.0.0.0 and its folder, but no Automate (unless that's what the ProjectTypeGuids DD87… & FAE0… are for):

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
 <PropertyGroup>
   <LangVersion>7.2</LangVersion>
   <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
   <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
   <ProjectGuid>{50097A1D-91A2-47D8-99D4-800ECC741F63}</ProjectGuid>
   <ProjectTypeGuids>{DD87C1B2-3799-4CA2-93B6-5288EE928820};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
   <OutputType>Library</OutputType>
   <AppDesignerFolder>Properties</AppDesignerFolder>
   <RootNamespace>cAlgo</RootNamespace>
   <AssemblyName>mjsEMA_2019net4</AssemblyName>
   <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
   <TargetFrameworkProfile>Client</TargetFrameworkProfile>
   <FileAlignment>512</FileAlignment>
   <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
 </PropertyGroup>
 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
   <DebugSymbols>true</DebugSymbols>
   <DebugType>full</DebugType>
   <Optimize>false</Optimize>
   <OutputPath>bin\Debug\</OutputPath>
   <DefineConstants>DEBUG;TRACE</DefineConstants>
   <ErrorReport>prompt</ErrorReport>
   <WarningLevel>4</WarningLevel>
   <WarningsAsErrors>CS0108,CS0162,CS0109,CS0169,CS0628</WarningsAsErrors>
 </PropertyGroup>
 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
   <DebugType>pdbonly</DebugType>
   <Optimize>true</Optimize>
   <OutputPath>bin\Release\</OutputPath>
   <DefineConstants>TRACE</DefineConstants>
   <ErrorReport>prompt</ErrorReport>
   <WarningLevel>4</WarningLevel>
   <WarningsAsErrors>CS0108,CS0162,CS0109,CS0169,CS0628</WarningsAsErrors>
 </PropertyGroup>
 <ItemGroup>
   <Reference Include="System" />
   <Reference Include="System.Core" />
   <Reference Include="System.Xml.Linq" />
   <Reference Include="System.Data.DataSetExtensions" />
   <Reference Include="System.Data" />
   <Reference Include="System.Xml" />
   <Reference Include="cAlgo.API, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3499da3018340880, processorArchitecture=MSIL">
     <SpecificVersion>False</SpecificVersion>
     <HintPath>..\..\..\..\API\cAlgo.API.dll</HintPath>
   </Reference>
 </ItemGroup>
 <ItemGroup>
   <Compile Include="mjsEMA_2019net4.cs" />
   <Compile Include="Properties\AssemblyInfo.cs" />
 </ItemGroup>
 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
      Other similar extension points exist, see Microsoft.Common.targets.
 <Target Name="BeforeBuild">
 </Target>
 <Target Name="AfterBuild">
 </Target>
 -->
</Project>

 

The strange thing is the reinstall didn't seem to change cAlgo.API.dll, unless it came with the same date but possibly contained a different Registry entry name or direct link to a different broker's AppData/…/cTrader/hexfolder copy of the app?


@martins

firemyst
26 Nov 2024, 00:57

I don't know what the issue is from looking at the files you posted.

However, brute force way to try and fix it (no guarantees!) – take a backup copy of your actual C# code.

Delete the indicator/cbot from cTrader.

Once deleted, go back and create a new indicator/cbot, adding references as appropriate.

Build it in cTrader.

Then select to edit in Visual studio.

Paste in your C# code from your backup.

hopefully it'll then build successfully.

The only drawback with this approach is if you have anything saved in a “template”, it may have to be readded.


@firemyst

martins
26 Nov 2024, 14:14 ( Updated at: 26 Nov 2024, 15:50 )

RE: Legacy Build with Visual Studio 2019 fails with error "No cTrader or cAlgo was found with version 1.20 or higher"

firemyst said: 

I don't know what the issue is from looking at the files you posted.

However, brute force way to try and fix it (no guarantees!) – take a backup copy of your actual C# code.

Delete the indicator/cbot from cTrader.

Once deleted, go back and create a new indicator/cbot, adding references as appropriate.

Build it in cTrader.

Then select to edit in Visual studio.

Paste in your C# code from your backup.

hopefully it'll then build successfully.

The only drawback with this approach is if you have anything saved in a “template”, it may have to be readded.

Sorry, thanks but I did say “Update: solved by uninstall/reinstall. Don't think it was the dll” - I got the unchanged source to compile/build properly by uninstalling & reinstalling cTrader using the saved ctrader…setup.exe I'd previously used when the 4.9.2 installed. It downloaded the same old version 4.9.2, then proceeded to download the update 5.0.46 whilst displaying an option to “start ctrader” which i clicked and 4.9.2 started up, or by clicking the taskbar icon 5.0.46 starts up. After the install finished VS 2019 build was ok.

However the resultant .algo and other non-recompiled algos immediately crash if run in 4.9.2 on that pc system (log line 1: "…started", line 2: “…crashed with error #3804C3AC”). (whereas on another older pc with 4.9.2 [it also autoupdated to 5.0.46 too but can still start using AppData…cTrader_4.9.2.26009.exe] I can still run them ok, using same .algo files copied from the newer & now ‘bad’ pc). So the remaining problem is it seems something got removed by the uninstall/reinstall (on the newer pc) that is required for 4.9.2 backtest of net4 cBots to work (I also reinstalled the vsix on VS2019, but can't be that else they'd also not work when .algo file copied to other system). 
Process Monitor shows the old system that works is using awsglobal for the tcp, whereas the new one where 4.9.2 backtest fails seems to load the algo file, read the csv data file many times, then some certificates, then gives up soon after looking in several folders for and not finding System.Net.Sockets.resources.dll

I can develop on 5.0.46 fine, the whole point of using 4.9.2 is to EXACTLY reproduce old backtest results.
v5.0 has more accurate treatment of swap and no compatibility option, so nothing reproduces exactly, order timing changes, pseudo random numbers used up at a different rate, so you can't tell whether some change in backtest results was due to a subtle cBot logic alteration, or due to the version of cTrader & its treatment of swap. 
More importantly: without a pre-swap-changes (or whatever, the ‘old’) version of cTrader (or a compatibility mode in the new one) there's no opportunity to examine & UNDERSTAND exactly why the backtest result is different - by rerunning/comparing the old vs the new with extra debug log messages etc (having locked down the price data by using csv files so it can't change which otherwise it seems to) - I though first rule of computing was “only one change at a time” but autoupdating software makes that difficult. 


@martins