Solved

Assembly.GetExecutingAssembly() for an assembly other than current executing

Posted on 2015-02-20
3
91 Views
Last Modified: 2015-02-20
I'm in a common assembly and I need the version number off the web assembly. I prefer not to have to new anything up to get it.

Is there a right way to do this?

I'm interested in keeping the auto incrementing version of the web project in sync with the auto incrementing version of the common project. I prefer to not have to manually increment in the AssemblyInfo.cs for both projects. I prefer to not have to reference the web assembly from the common assembly in order to get the version for the web assembly.
0
Comment
Question by:gswitz
3 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 40621146
You probably want GetCallingAssembly() which will return the Assembly that invoked the method call, rather than the assembly in which the called method resides.
0
 
LVL 20

Accepted Solution

by:
Daniel Van Der Werken earned 500 total points
ID: 40621318
Not 100% sure what you're trying to do or not trying to do. Here's how I'd get the version of any assembly:

FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(filePath);

Open in new window


Grab the version and then add it back into the AssemblyInfo.cs file prior to your build. Make that a pre-build step.
0
 

Author Closing Comment

by:gswitz
ID: 40621328
Thanks, that should work.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question