One of my products has been acting “funny” for a while and I have not been able to figure out what exactly the problem was, until this past weekend.
I display the application version number on the status bar and after an update (unknown as to what, Windows, VS, or what), it started showing 0.0.0.0.
I have been using the Automatic Versions plugin for Visual Studio which has been working great – except for the fact the version number is not being shown.
When the problem first surfaced, I had a lot on my plate and just ended up hard-coding the current version into the application. This was a huge pain in the butt and last weekend I finally decided to track it down.
Finding #1: No Assembly Information
If you navigate to Project, Settings, and click the Assembly Information button, you should see your project properties. Mine was blank. This was really odd because my AssemblyInfo.cs was fully-populated with data.
Finding #2: The property could not be read/written because the language service returned an unknown error.
When I manually try and set a property via the Assembly Information dialog, I received this error. This was actually a good thing because it gave me something to search for.
Many of the solutions I was able to retrieve on this error involved creating a new project and copying everything over to the new project. While this may solve the issue, I was really not in the mood to do this.
This application started off way back in 2012 and was creating using VS 2010. It has been upgraded to 2013, 2015, and now 2017 (I skipped 2012). The possibility that something was wrong with the configuration was very high, I just needed to find out what exactly.
Since everything compiled and ran without issue, that lead me to the possibly that maybe only part of the project was invalid.
Since the error surfaced when editing the Assembly Information, I started there. I made a copy of the AssemblyInfo.cs file then deleted the file.
Next, I went to Project, Settings, and clicked the Assembly Information button, changed one of the settings, and clicked OK.
A new AssemblyInfo.cs file was created and the version number was again being reported properly. And the Automatic Versions plugin was working as initially configured.
I can only guess that there was a setting in the older the AssemblyInfo.cs file that was causing something in Visual Studio to have an issue. I didn’t do a file comparison, but either one of the attributes was invalid or there was unseen corruption in the file itself.