471,354 Members | 1,327 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Retrieving Application Information?

Is there a way to retrieve a WinForms application information such as
Company, Product and Version from within a
class library ( DLL ) that the Winforms application is using. Specificly the
applications specfic ApplicationData directory.
This is not a problem from within the application, all you need to do is use
Application.UserAppDataPath but I need this
same location from inside the class library ( DLL ). C# example would be
nice! Thanks....

Orgbrat

Jan 27 '06 #1
2 4332
You can set this information using the appropriate tags in the
Assemblyinfo.cs class file. You can retrieve it using the appropriate
methods such as GetCustomAttributes.

Here's a short snippet that gets the AssemblyConfiguration item:

private string buildMode=String.Empty;
private void Page_Load(object sender, System.EventArgs e)
{
Assembly asm = Assembly.GetExecutingAssembly();
object[] objArray=asm.GetCustomAttributes(false) ;
foreach (object obj in objArray)
{
AssemblyConfigurationAttribute conf =
obj as AssemblyConfigurationAttribute;
if (conf != null)
this.buildMode=conf.Configuration ;
}
Response.Write("Build Mode: " +this.buildMode);
}

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Orgbrat" wrote:
Is there a way to retrieve a WinForms application information such as
Company, Product and Version from within a
class library ( DLL ) that the Winforms application is using. Specificly the
applications specfic ApplicationData directory.
This is not a problem from within the application, all you need to do is use
Application.UserAppDataPath but I need this
same location from inside the class library ( DLL ). C# example would be
nice! Thanks....

Orgbrat

Jan 27 '06 #2
Hi Peter,
Thank you very much for your input. I just needed a push in the right
direction. I needed to use the
Assembly.GetEntryAssembly() call instead of the
Assembly.GetExecutingAssembly() call to find what
I needed. Thanks a very lot you were a great help.

Orgbrat

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:8E**********************************@microsof t.com...
You can set this information using the appropriate tags in the
Assemblyinfo.cs class file. You can retrieve it using the appropriate
methods such as GetCustomAttributes.

Here's a short snippet that gets the AssemblyConfiguration item:

private string buildMode=String.Empty;
private void Page_Load(object sender, System.EventArgs e)
{
Assembly asm = Assembly.GetExecutingAssembly();
object[] objArray=asm.GetCustomAttributes(false) ;
foreach (object obj in objArray)
{
AssemblyConfigurationAttribute conf =
obj as AssemblyConfigurationAttribute;
if (conf != null)
this.buildMode=conf.Configuration ;
}
Response.Write("Build Mode: " +this.buildMode);
}

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Orgbrat" wrote:
Is there a way to retrieve a WinForms application information such as
Company, Product and Version from within a
class library ( DLL ) that the Winforms application is using. Specificly
the
applications specfic ApplicationData directory.
This is not a problem from within the application, all you need to do is
use
Application.UserAppDataPath but I need this
same location from inside the class library ( DLL ). C# example would be
nice! Thanks....

Orgbrat

Jan 27 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Ian Williamson | last post: by
reply views Thread by Rob Meade | last post: by
3 posts views Thread by Navodit | last post: by
1 post views Thread by jimmyfo | last post: by
11 posts views Thread by Nemisis | last post: by
3 posts views Thread by Bruno Vignola | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.