I’m working on set of webparts that uses common library.
To testing deployment I need to add version info in generated html. Method that add version “watermark” to page is in common library.
So I have something like this (it is more complicated, because in common library is base class for webparts, but for this problem we can simplify it):
In control from mainAssembly.dll I’m calling OnInit method:
protected override void OnInit(EventArgs e)
{
..
Library.AddWatermark(this);
..
}
and in common library I have:
public void AddWatermark(Control ctrl)
{
string assemblyVersion = GetAssemblyVersion();
ctrl.Controls.Add(new HiddenField { Value = string.Format("Version: {0}", assemblyVersion ) });
}
So my question is: how to get version of assembly when we are in method from this assembly? (in AddWatermark)? And if it is possible to get version of caller assembly? (mainAssembly)
Try to use