I am really confused I have written some code that is reading some records from a database. If I compile it as an Application it works fine. If I compile it as a .dll and I call the .dll from another application the code doesn't work anymore (it returns all zeroes). This code is called in the Form_onShown()
Portfolios.Add(new NPortfolio(1, "1", activeContracts));
Dictionary<string, double> p = db.GetPortfolio(1,Today);
Portfolios[0].UpdatePositions(p);
var strContracts = new List<string>();
strContracts.Add(pf.p_id);
strContracts.AddRange(pf.getPositions().Select(o => o.Value.ToString()).ToList());
this return my stored database values when compiled as .exe and returns all 0 when compiled as .dll!!
the NPortfolio class is defined as follows:
public NPortfolio(int nr, string id, List<string> ac)
{
p_nr = nr;
p_id = id;
positions = new Dictionary<string, double>();
foreach (string ticker in ac)
{
positions.Add(ticker, 0.00);
}
}
public void UpdatePositions(Dictionary<string, double> position)
{
foreach (var k in this.getPositions().Keys.ToList())
{
if (position.ContainsKey(k))
{
this.positions[k] = position[k];
}
}
}
public Dictionary<string, double> getPositions()
{
return positions;
}
}
Any suggestion?
R.