Solved

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

Posted on 2015-02-20
3
88 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Json POSt to Rest API 4 60
C# guarantee sql connection close 6 39
Problem!!! 8 33
Calculate number of nights between two dates 5 18
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 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