How to get executing assembly path (for robot)

Created at 22 Jun 2013, 21:04
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!
SO

SonnyJim

Joined 22.06.2013

How to get executing assembly path (for robot)
22 Jun 2013, 21:04


I found cAlgo doesn't like the Assembly namespace. 

eg.

var a = Assembly.GetEntryAssembly().Location; 

throws a NullReferenceException

 

For now all I can do is hardcode or perhaps use the Environment special folders perhaps.


@SonnyJim
Replies

algotrader
22 Jun 2013, 22:34

Why do you need Assembly.Location?


@algotrader

SonnyJim
23 Jun 2013, 01:30

RE:
algotrader said:

Why do you need Assembly.Location?

It's to load an xml file. Yes I can hard code the location, but...


@SonnyJim

algotrader
23 Jun 2013, 11:07

RE: RE:
SonnyJim said:
algotrader said:

Why do you need Assembly.Location?

It's to load an xml file. Yes I can hard code the location, but...

I agree that hard coding location isn't good practice. You can put your xml file in Robots folder and find path to it using this code:

var pathToRobotsFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "cAlgo", "Robots");




@algotrader