Unable to load assembly: Assembly must contain single algo type

Created at 22 Jan 2013, 00: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!
RM

rmakarev

Joined 28.11.2012

Unable to load assembly: Assembly must contain single algo type
22 Jan 2013, 00:31


Hi Support,

After a recent update I see the error in subj.

Tried to recompile with the latest calgo.API.DLL. Nothing helps.

What does this error mean? What exactly is checked while loading an assembly?

 

Thanks


@rmakarev
Replies

admin
22 Jan 2013, 09:59

Hello,

What are the circumstances under which you see the error? Is it a robot build? If so, is it possible to post the code or email the code to us at engage@ctrader.com so that we can take a look?


@admin

rmakarev
22 Jan 2013, 23:16

Hello,

I have a project in Visual Studio 2012 (DLL). My DLL contains class BaseRobot. BaseRobot is a direct subclass of cAlgo.API.Robot. I add a reference to my DLL and use my class BaseRobot as a superclass for all my robots in cAlgo. It used to work without any problems but know it does not work. I have a suspicion that the problems are caused by a recent cAlgo update.

Technically it seems to be caused by the fact that my robots in cAlgo are NOT DIRECT subclasses of cAlgo.API.Robot but they are subclasses of my own BaseRobot that is a DIRECT subclass of cAlgo.API.Robot. Everything seems to be correct on my side.

Is there any requirement to extend cAlgo.API.Robot ONLY DIRECTLY ???

Thanks.


@rmakarev

admin
23 Jan 2013, 09:20

No there is no such requirement. Try recompiling the base class file and then see if this solves the issue.


@admin

rmakarev
23 Jan 2013, 15:21

Hello,

I tried to recomplile my DLL many times. It does not work out.

The the problem is reproducible if my robot in cAlgo extends BaseRobot (from my own DLL) that extends Robot.

It works without any problems if my robot in cAlgo extends Robot directly.

I also tried to create a local instance of BaseRobot in OnStart() method in cAlgo:

 

class RobotInCAlgo : Robot

{

  OnStart()

  {

    Robot r = new BaseRobot();

  }

}

The code above also works perfect (without any class cast issues) which means that BaseRobot was correctly inherited from Robot.

I have a suspicion that cAlgo assembly loader checks if the parent is Robot and fails if it is not. In my case robots in cAlgo have BaseRobot as a parent class which causes the described problem.

 

It seems to be a problem of the latest cAlgo update.

 

Thanks.


@rmakarev

admin
23 Jan 2013, 16:42

Yes, you are correct. This functionality has been removed since the latest update. If the purpose of doing this is to hide the code, you may easily do so by distributing the compiled file (.algo file) and a text file (.cs file) that has the same name but does not contain any code. Probably, you should include some comments in the text file, like do not build or modify this file, etc. If the reason is different may we ask you to let us know about it, so that we can decide on an appropriate course of action. Thank you in advance.


@admin

rmakarev
24 Jan 2013, 01:49

Thanks a lot!

The actual reason is that I have a few robots inhereted from BaseRobot. BaseRobot contains some core functionality for advanced logging and configuration of my robots. This is about the object-oriented architecture of my system built on top of cAlgo. I do not want to merge all things to a single class and duplicate the code.

I have a couple of ideas how to change my architecture and work around your new limitation but I would prefer to keep it as is.

Just let me know if you are not going to remove the limitation or you want to change it back so I can change my code accordingly.

Thank you!


@rmakarev

admin
24 Jan 2013, 11:00

The reason inheritance of robot classes is no longer supported is for better performance. The only change that can be made is that inheritance may be supported for as long as no metadata is in the base class. In other words, attributes (IndicatorAttribute, RobotAttribute, ParameterAttribute, OutputAttribute, etc) are not included in the base class. Let us know if this is something usefull to you and we will request an implementation for it.


@admin

rmakarev
25 Jan 2013, 16:07

Hello,

I would be a great solution. I do not need attributes in base classes. However the inheritance is still very important for me so I hope you can remove inheritance limitations in recent cAlgo updates.


Thanks.


@rmakarev

rmakarev
25 Jan 2013, 16:08

Hello,

It would be a great solution. I do not need attributes in base classes. However the inheritance is still very important for me so I hope you can remove inheritance limitations in recent cAlgo updates.


Thanks.


@rmakarev

admin
25 Jan 2013, 17:50

Thank you for your response. The limitation will be removed in one of the next releases.


@admin

AlexanderRC
14 Mar 2014, 23:57

RE:

admin said:

Thank you for your response. The limitation will be removed in one of the next releases.

Has it been removed? 


@AlexanderRC

Spotware
17 Mar 2014, 10:05

No, it wasn't. Currently we are not going to remove such limitation.

If you want to reuse some code it is recommended to extract such code to class library and reference it from other cBots.


@Spotware