9

I am having a hard time getting version info in my assembly/exe. There seem to be a lot of questions regarding this but none help me with resolving the issue.

It seems to basic and simple to be able to include version info in my exe, but it does not show up when I look in the context menu from explorer (right click->properties->details)

How can I add version info (Without using plugins) to my C# compact framework/WinMobile 6.0 project?

Here is the default assemblyinfo.cs

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TestingVerInfo")]
[assembly: AssemblyDescription("hello")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("world")]
[assembly: AssemblyProduct("TestingVerInfo")]
[assembly: AssemblyCopyright("Copyright ©  2011")]
[assembly: AssemblyTrademark("gggg")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5e5fffea-0c9d-4394-9a0f-d24b7e7db9ed")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
[assembly: AssemblyVersion("1.0.0.0")]

And here is the less than impressive file details:

enter image description here

Tim
  • 20,184
  • 24
  • 117
  • 214

2 Answers2

6

Maybe I don't understand the question, but including version info is as simple as setting the assembly: [AssemblyVersion][1] attribute. You can query it back using something like this:

 var version = Assembly.GetExecutingAssembly().GetName().Version;

UPDATE

Well here's a really strange behavior. I knew that I had version info in my apps and assemblies, so I opened up Studio and created a new Smart Device project and left all of the defaults. Sure enough, I got the behavior you see - that is to say no version info. WTF? I went back and opened a stub project that did have the version info in the binary and the AssemblyInfo.cs file really was no different.

I played around a bit and it turns out that if you change the target platform of your Project From "Windows Mobile Xxxx" to "Windows CE" (you can still deploy to a WinMo target if you do this) then the version info does end up in the binary. No idea why this might be the case - the compiler command line for the WinMo configuration must be different than the CE configuration.

ctacke
  • 66,480
  • 18
  • 94
  • 155
  • I would have thought it was as simple as that - but I am using the default assemblyinfo.cs and nothing is shown when I look at the properties for the output/built exe. – Tim Oct 25 '11 at 17:00
  • "Look" at the properties how? From Explorer? I just checked mine locally on files I just built (both DLL and EXE) and the results were expected. I saw under Properties -> Details the values set in assemblyinfo.cs. I know it works programmatically because I have applications that show the version number in the form header. – ctacke Oct 25 '11 at 17:08
  • You are talking about CF/Windows Mobile 6.5? – Tim Oct 25 '11 at 17:10
  • OK, thanks. I will test a brand new project in that case. But I don't see any version info for my app in explorer... See edits to question. I just created a new project and it has NO version info available to the OS... – Tim Oct 25 '11 at 18:02
  • I have not tried it yet - but thanks for checking on this. this is yet one more think in CF that is frustrating as hell... – Tim Oct 31 '11 at 03:58
1

Applications generated for Windows Mobile are not created using a standard Windows operating system executable format. This means that the Windows operating system that you are running does not know how to extract the information from the file in order to populate the details tab.

Having said that, the version information is still embedded in the application and is available on the mobile device. If you need to present this information to your users within your application (the about box, for example), there are ways to retrieve this data using coredll methods including GetFileVersionInfo and VerQueryValue.

Our class to retrieve this data is about 350 lines long, so I didn't think it appropriate to post here and I could not quickly find the source where we got the original idea from. I can do additional research on this if needed.

competent_tech
  • 44,465
  • 11
  • 90
  • 113
  • 2
    I disagree. It's still a PE with a PE header, and still has resources in the same format. – ctacke Oct 31 '11 at 03:29
  • I need to have the version information so that I can provide support and log issues correctly against the versions. it is likely that we will have a lot of different versions of the software deployed and need to keep tabs on them. I would like to push deployments automatically, but not sure that is feasible any time soon. – Tim Oct 31 '11 at 04:00
  • If you are ok with retrieving the version information at runtime, then this is very easy to do: System.Reflection.Assembly.GetExecutingAssembly.GetName.Version. As far as automatic deployments, we spent at least 2 months working on a project for this, but I was never completely satisfied with the results. Our scenario was complicated by a local database that, for the purpose of auto-upgrade, we had to keep in a separate location. We later got this working very successfully in a full windows app (running on tablets) by creating a shell app that performed the update, then launched the real app. – competent_tech Oct 31 '11 at 16:26
  • @ctacke - I apologize, I should have been more precise in my answer. The executables for windows mobile (my experience is with 6 and earlier) do not contain all of the same resources that those generated for Windows OSs contain. Among the missing resources is the Version resource, which is what Windows Explorer uses to display the version information in the properties dialog. – competent_tech Oct 31 '11 at 16:50