Error CT0001: Unable to cast object of type 'System.Xml.XmlComponent' to type 'System.Xml.XmlElement'.
Error CT0001: Unable to cast object of type 'System.Xml.XmlComponent' to type 'System.Xml.XmlElement'.
26 May 2022, 14:37
The cTrader builder fails with Error CT00001: Unable to cast object of type 'System.Xml.XmlComponent' to type 'System.Xml.XmlElement' if the .csproj file contains any comments. Additionally, the builder does not support implicit using and fails with an Error CS0103 if enabled. This leads to a question, is there a way to build an algo with the source code using the dotnet build or MSBuild with a parameter instead of relying on the integrated builder?
Replies
Jiri
27 May 2022, 09:56
Thanks for sharing this with me but it's not fixing the Error CT0001. Furthermore, I asked if it's possible to control whether the dotnet build should include the source code or not by using build properties passed as a parameter.
Amusleh, if you don't have an answer then let me know. I feel like many of my questions are being ignored making me repeat the same question multiple times hoping for an answer. I would highly appreciate it if we can make the communication more efficient.
@Jiri
amusleh
27 May 2022, 10:20
Hi,
I tested implicit usings and XML comments, they work if you select the SDK compiler,
So if you change the compiler from embedded to SDK both of those issues will be resolved, and regarding building with source code, you can build with source code with SDK compiler from cTrader itself if you change the compiler to SDK.
And I'm not aware of any parameter that allows building with source code via dotnet CLI.
In my previous message I guided you on how to change the compiler because by changing the compiler both of your issues will be resolved.
@amusleh
Jiri
27 May 2022, 10:38
On my end, it fixed implicit usings but not comments in the .csproj. Please, try the project below.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<!--<LangVersion>latest</LangVersion>-->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="cTrader.Automate" Version="1.*" />
</ItemGroup>
</Project>
using cAlgo.API;
namespace cAlgo
{
[Indicator(AccessRights = AccessRights.None)]
public class ErrorCT0001 : Indicator
{
protected override void Initialize()
{
Print($"The PI value is '{Math.PI}'.");
}
public override void Calculate(int index) { }
}
}
@Jiri
amusleh
27 May 2022, 10:49
RE:
Jiri said:
On my end, it fixed implicit usings but not comments in the .csproj. Please, try the project below.
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net6.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <!--<LangVersion>latest</LangVersion>--> </PropertyGroup> <ItemGroup> <PackageReference Include="cTrader.Automate" Version="1.*" /> </ItemGroup> </Project>
using cAlgo.API; namespace cAlgo { [Indicator(AccessRights = AccessRights.None)] public class ErrorCT0001 : Indicator { protected override void Initialize() { Print($"The PI value is '{Math.PI}'."); } public override void Calculate(int index) { } } }
Hi,
I was able to reproduce the issue, it happens only if you put the comment tag inside another child tag like PropertyGroup or ItemGroup, but if you put it outside a child tag it works fine.
We will investigate this issue, thanks for reporting.
@amusleh
amusleh
27 May 2022, 09:17
Hi,
You can change the cTrader compiler from embedded to SDK from cTrader Settings -> Automate tab.
@amusleh