Cast error in cTrader project

Created at 10 Nov 2023, 05:31
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!
NO

noppanon

Joined 17.05.2017

Cast error in cTrader project
10 Nov 2023, 05:31


Hi Support,

   I have the error casting error when I put this code in cTrader. It works on other application. The code try to get image from embedded resource and covert to Stream. I use .Net 6.0.415, cTrader 4.8.28.

 

09/11/2023 21:17:06.333 | <indicator name>[EURUSD] OnNewBar()  got error 

'[A]System.Drawing.Bitmap cannot be cast to [B]System.Drawing.Bitmap. 

Type A originates from 'System.Drawing.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=<the key>' in the context 'Default' at location 'C:\Users\<my folder>\Spotware\dotnet\shared\Microsoft.WindowsDesktop.App\6.0.0\System.Drawing.Common.dll'. 

Type B originates from 'System.Drawing.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=<the key>' in the context 'Default' in a byte array.'

here is the code. The error happened at  line (3)

        1.   Stream logo; 
        2.   System.Drawing.Bitmap image = null; 
        3.   image = Properties.Resources.Bull_Bear_Caution; 
        4.   logo = new System.IO.MemoryStream(); 
        5.   Properties.Resources.Bull_Bear_Caution.Save(logo, ImageFormat.Png); 
        6.   logo.Position = 0; 

 

Thanks in advance.
Noppanon

 


@noppanon
Replies

PanagiotisCharalampous
10 Nov 2023, 07:10

Hi Noppanon,

Unfortunately it is not possible to determine the problem with this information. Please send us the complete solution file to community@spotware.com

 


@PanagiotisCharalampous

noppanon
10 Nov 2023, 09:51

RE: Cast error in cTrader project

PanagiotisCharalampous said: 

Hi Noppanon,

Unfortunately it is not possible to determine the problem with this information. Please send us the complete solution file to community@spotware.com

 

Hi Support,

   I will create a simple indicator to reproduce the error. Please wait a couple days.

Noppanon


@noppanon

noppanon
10 Nov 2023, 23:30 ( Updated at: 11 Nov 2023, 07:05 )

RE: RE: Cast error in cTrader project

noppanon said: 

PanagiotisCharalampous said: 

Hi Noppanon,

Unfortunately it is not possible to determine the problem with this information. Please send us the complete solution file to community@spotware.com

 

Hi Support,

   I will create a simple indicator to reproduce the error. Please wait a couple days.

Noppanon

Hi Support,

   Please download my solution from this link.

https://drive.google.com/file/d/1QXIlnSYDMtlEIWfxrd8LT2Ddm4qh5X8k/view?usp=sharing

 

Noppanon


@noppanon

noppanon
13 Nov 2023, 09:29 ( Updated at: 13 Nov 2023, 14:21 )

RE: RE: RE: Cast error in cTrader project

noppanon said: 

noppanon said: 

PanagiotisCharalampous said: 

Hi Noppanon,

Unfortunately it is not possible to determine the problem with this information. Please send us the complete solution file to community@spotware.com

 

Hi Support,

   I will create a simple indicator to reproduce the error. Please wait a couple days.

Noppanon

Hi Support,

   Please download my solution from this link.

https://drive.google.com/file/d/1QXIlnSYDMtlEIWfxrd8LT2Ddm4qh5X8k/view?usp=sharing

 

Noppanon

May I have some update, please?


@noppanon

PanagiotisCharalampous
13 Nov 2023, 14:39 ( Updated at: 13 Nov 2023, 14:40 )

RE: RE: RE: RE: Cast error in cTrader project

noppanon said: 

noppanon said: 

noppanon said: 

PanagiotisCharalampous said: 

Hi Noppanon,

Unfortunately it is not possible to determine the problem with this information. Please send us the complete solution file to community@spotware.com

 

Hi Support,

   I will create a simple indicator to reproduce the error. Please wait a couple days.

Noppanon

Hi Support,

   Please download my solution from this link.

https://drive.google.com/file/d/1QXIlnSYDMtlEIWfxrd8LT2Ddm4qh5X8k/view?usp=sharing

 

Noppanon

May I have some update, please?

Hi Noppanon,

I have responded via Telegram


@PanagiotisCharalampous