CT0001 Object reference not set to an instance of an object.

Created at 17 Oct 2022, 22:46
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!
EY

eynt

Joined 08.05.2020

CT0001 Object reference not set to an instance of an object.
17 Oct 2022, 22:46


Hello

 

When creating a new bot/indicator (with the default code of cTrader) I get the following error when I try to build the project with Visual Studio 2022. (it does not happen when I build the bot/indicator from the cTrader:

Error    CT0001    Object reference not set to an instance of an object.    New Indicator (7)    C:\Users\yuval\.nuget\packages\ctrader.automate\1.0.3\build\cTrader.Automate.targets    62    

The targets file looks as seen below.

I am not 100% sure when it started, but it's possible that it started once I opened a new account on a second broker and installed its cTrader windows app.

Please note that the error occurs on several PCs and not just one, even those which did not install the new broker cTrader windows app.

If it helps you can find a new bot sample with ctrader.automate here: 

<!--
***********************************************************************************************
Sdk.targets

WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
          created a backup copy.  Incorrect changes to this file will make it
          impossible to load or build your projects from the command-line or the IDE.

Copyright © Spotware Systems Ltd. All rights reserved.
***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <PropertyGroup>
        <_AlgoFileName>$(AlgoName).algo</_AlgoFileName>
        <_AlgoFilePath>$(OutDir)$(_AlgoFileName)</_AlgoFilePath>
        <_AlgoMetadataFileName>$(_AlgoFileName).metadata</_AlgoMetadataFileName>
        <_AlgoMetadataFilePath>$(OutDir)$(_AlgoMetadataFileName)</_AlgoMetadataFilePath>
        <_AlgoIconPath Condition="'$(AlgoIcon)' != ''">$([System.IO.Path]::GetFullPath('$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)','$(AlgoIcon)'))'))</_AlgoIconPath>
    </PropertyGroup>

    <PropertyGroup>
        <_TaskAssemblyTFM Condition="'$(MSBuildRuntimeType)' == 'Core'">net6.0</_TaskAssemblyTFM>
        <_TaskAssemblyTFM Condition="'$(MSBuildRuntimeType)' != 'Core'">net472</_TaskAssemblyTFM>
        <_TaskAssembly>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\tools\$(_TaskAssemblyTFM)\cTrader.Automate.Sdk.Tasks.dll))</_TaskAssembly>
    </PropertyGroup>

    <ItemGroup Condition="('$(UseWPF)' == 'True' OR '$(UseWindowsForms)' == 'True') AND ('$(TargetFrameworkVersion)' == 'v6.0' OR '$(TargetFrameworkVersion)' == '6.0')">
        <FrameworkReference
                Update="Microsoft.WindowsDesktop.App;Microsoft.WindowsDesktop.App.WPF;Microsoft.WindowsDesktop.App.WindowsForms"
                TargetingPackVersion="6.0.0"/>
    </ItemGroup>
    
    <ItemGroup Condition="'$(EnableDefaultAlgoSetItems)' == 'True'">
        <AlgoSet Include="$(MSBuildProjectDirectory)\**\*.cbotset" />
        <AlgoSet Include="$(MSBuildProjectDirectory)\**\*.indicatorset" />
    </ItemGroup>

    <UsingTask TaskName="ExtractMetadataTask"
               AssemblyFile="$(_TaskAssembly)"/>
    <UsingTask TaskName="BundleAlgoTask"
               AssemblyFile="$(_TaskAssembly)"/>
    <UsingTask TaskName="GetAlgoPublishDirTask"
               AssemblyFile="$(_TaskAssembly)"/>
    
    <Target Name="_ValidateProps">
        <Error Condition="'$(StoreSaleType)' != 'free' AND '$(StoreSaleType)' != 'paid'" Text="Unexpected 'StoreSaleType' property value." />
        <Error Condition="'$(StoreAccessType)' != 'public' AND '$(StoreAccessType)' != 'private'" Text="Unexpected 'StoreAccessType' property value." />
    </Target>

    <Target Name="_ExtractMetadata" DependsOnTargets="FindReferenceAssembliesForReferences">
        <ExtractMetadataTask AssemblyPath="$(TargetPath)"
                             ReferencePath="@(ReferencePathWithRefAssemblies)"
                             AlgoSetFiles="@(AlgoSet)"
                             OutputPath="$(_AlgoMetadataFilePath)"/>

        <Message Importance="Normal"
                 Text="$(MSBuildProjectName) -> $([System.IO.Path]::GetFullPath($(_AlgoMetadataFilePath)))"/>
    </Target>

    <Target Name="_BundleAlgo" DependsOnTargets="ComputeFilesToPublish">
        <BundleAlgoTask Name="$(AlgoName)"
                        Version="$(AlgoVersion)"
                        Description="$(Description)"
                        FilesToBundle="@(ResolvedFileToPublish)"
                        MetadataPath="$(_AlgoMetadataFilePath)"
                        ProjectDir="$(ProjectDir)"
                        TargetFramework="$(TargetFramework)"
                        IncludeSource="$(IncludeSource)"
                        IncludeSymbols="$(IncludeSymbols)"
                        IconPath="$(_AlgoIconPath)"
                        StoreSaleType="$(StoreSaleType)"
                        StoreAccessType="$(StoreAccessType)"
                        OutputPath="$(_AlgoFilePath)"/>

        <Message Importance="High"
                 Text="$(MSBuildProjectName) -> $([System.IO.Path]::GetFullPath($(_AlgoFilePath)))"/>
    </Target>

    <Target Name="_GetAlgoPublishDir">
        <GetAlgoPublishDirTask MetadataPath="$(_AlgoMetadataFilePath)">
            <Output TaskParameter="OutputPath"
                    PropertyName="_AlgoPublishDir"/>
        </GetAlgoPublishDirTask>
    </Target>

    <Target Name="_CopyToSources"
            Condition="'$(AlgoPublish)' == 'true'"
            DependsOnTargets="_GetAlgoPublishDir">
        <ItemGroup>
            <_AlgoFile Include="$(_AlgoFilePath)"/>
        </ItemGroup>

        <Copy SourceFiles="@(_AlgoFile)"
              DestinationFolder="$(_AlgoPublishDir)"
              OverwriteReadOnlyFiles="True"
              Retries="10"
              RetryDelayMilliseconds="100"/>

        <Message Importance="High"
                 Text="$(MSBuildProjectName) -> $(_AlgoPublishDir)\$(_AlgoFileName)"/>
    </Target>

    <PropertyGroup>
        <_CoreAlgoBuildTargets>
            _ValidateProps;
            _ExtractMetadata;
            _BundleAlgo;
            _CopyToSources;
        </_CoreAlgoBuildTargets>
    </PropertyGroup>

    <Target Name="_AlgoBuildAfterBuild"
            AfterTargets="Build"
            Condition="'$(AlgoBuild)' == 'true'"
            DependsOnTargets="$(_CoreAlgoBuildTargets)">
    </Target>

</Project>

 


@eynt
Replies

eynt
17 Oct 2022, 23:14

RE:

Important update:

 

I believe I was able to fix this problem by the following actions from Visual Studio:

Right click the solution > Manage NuGet packages for solution > Downgrading cTrader.Automate from version 1.0.3 to 1.0.2

I believe there's some sort of a problem with the cTrader.Automate and I am looking forward to hearing your opinion about the subject.

 

Thank you


@eynt

Xammo
18 Oct 2022, 01:14

Thankyou! same problem here even on a new bot

object reference not set to an instance of an object  - cTrader.Automate.targets - line 62

Didn't think to downgrade thanks for the suggestion


@Xammo

RayAdam
18 Oct 2022, 01:51 ( Updated at: 21 Dec 2023, 09:22 )

RE: RE:

yuval.ein said:

Important update:

 

I believe I was able to fix this problem by the following actions from Visual Studio:

Right click the solution > Manage NuGet packages for solution > Downgrading cTrader.Automate from version 1.0.3 to 1.0.2

I believe there's some sort of a problem with the cTrader.Automate and I am looking forward to hearing your opinion about the subject.

 

Thank you

getting the same error with 1.0.3 which was published yesterday, 17 Oct.


@RayAdam

drewisdad
18 Oct 2022, 01:56 ( Updated at: 18 Oct 2022, 02:04 )

RE: RE: RE:

 

Nice pick up Ray :)  And nice quick fix yuval.ein.

I can see this thread getting alot of attention today :)

 

 

Just an edit... Spotware's testing phase before releases leave something to be desired.  A lot of bugs were introduced into their optimization area with their last update as well :(


@drewisdad

Waxy
18 Oct 2022, 04:05

This is quite an issue on 1.0.3, please fix as soon as possible.

Regards,


@Waxy

drewisdad
18 Oct 2022, 06:37

RE:

Yup, this is real prob.

Looks like downgrading to 1.02 allows for saving of existing projects.  But when creating new ones, the bin folder is not getting created.  So we get the error

Severity	Code	Description	Project	File	Line	Suppression State
Error	CS0006	Metadata file 'C:\Users\xxxx\Documents\cAlgo\Sources\Indicators\RBK\RBK\bin\Debug\net40\RBK.dll' could not be found	aaa_RBK	C:\Users\xxxx\Documents\cAlgo\Sources\Robots\aaa_RBK\aaa_RBK\CSC	1	Active

 


@drewisdad

Spotware
18 Oct 2022, 08:04

Dear traders, 

Thanks for reporting this issue. The team is aware of it and working on a solution. In the meanwhile, you need to downgrade the cTrader Automate package to 1.0.2.

Best regards,

cTrader Team


@Spotware

eynt
18 Oct 2022, 09:07

RE:

Spotware said:

Dear traders, 

Thanks for reporting this issue. The team is aware of it and working on a solution. In the meanwhile, you need to downgrade the cTrader Automate package to 1.0.2.

Best regards,

cTrader Team

 

Thank you for your response.

Please report on this forum thread once this issue is solved so we can get notified by email that it is fixed.


@eynt

drewisdad
18 Oct 2022, 13:25 ( Updated at: 18 Oct 2022, 13:26 )

RE: RE:

Fixed! :)

1.04 is available now :)

 


@drewisdad

drewisdad
20 Oct 2022, 06:20 ( Updated at: 20 Oct 2022, 06:35 )

Cannot add new references :(

Add them using 'manage references', but they are not found when I try to declare them in the code :(

 

I reverted back to 1.02 and still the same, they're not found...  

Shut VS down and re-opened.  same thing.

VS shows my dependency listed, but still will not let me build with the error "could not be found"

I've done a 'dotnet restore' in both 1.04 and 1.02.  for both the bot and the dependencies.

Made sure dependencies were updated / downgraded to the same nuget package as used in my cbot each time.

Existing dependencies that already lived in my bots still work... just cannot add new ones :( 


@drewisdad

PanagiotisChar
20 Oct 2022, 10:11

Hi drewisdad,

Try adding them as projects is your VS solution. Also make sure your projects are under the same namespace.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 


@PanagiotisChar

drewisdad
20 Oct 2022, 13:43 ( Updated at: 20 Oct 2022, 13:51 )

RE:

Thanks for the reply Sir.

All my projects are under the cAlgo namespace, either Robots or Indicators... soo not sure how to add them as projects in VS manually... I just right click on the Indicator or cBot in cTrader and select 'edit in Visual Studio'.

I can see the Indicator was added in VS solution explorer, but when I try and declare them in VS, I get the 'not found' error mentioned above.

 

Also have the same problem with cAlgo.API.Alert.  I get the error saying that it is 'Not Supported' when I add it via Nuget.  I checked if 4.5 wasn't installed (it seemed not to be), though when I tried to install framework 4.5 it returned... 

Microsoft .NET Framework 4.5 is already a part of this operating system.  You do not need to install the .NET Framework 4.5 redistributable.

Same or higher version of .NET Framework 4.5 has already been installed on this computer.

So I'm really thinking I'm about to lose it here haha.  Seriously though... it's starting to get beyond a joke for me :(

 

The VS Studio I'm using Info:-

Microsoft Visual Studio Community 2019
Version 16.11.18
VisualStudio.16.Release/16.11.18+32802.440
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Community

ASP.NET and Web Tools 2019   16.11.110.1451
ASP.NET and Web Tools 2019

Azure App Service Tools v3.0.0   16.11.110.1451
Azure App Service Tools v3.0.0

C# Tools   3.11.0-4.22108.8+d9bef045c4362fbcab27ef35daec4e95c8ff47e1
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

cAlgoPackage Extension   1.0
cAlgoPackage Visual Studio Extension Detailed Info

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

IntelliCode Extension   1.0
IntelliCode Visual Studio Extension Detailed Info

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

NuGet Package Manager   5.11.2
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

TypeScript Tools   16.0.30526.2002
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   3.11.0-4.22108.8+d9bef045c4362fbcab27ef35daec4e95c8ff47e1
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools   16.11.0-beta.21514.6+b6c2c4f53ea3a08fa603ea93d6d2f808a62a21d1
Microsoft Visual F# Tools

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

 


@drewisdad