1

Note that last time I asked this question it was wrongly closed as a duplicate of this question which does not answer my question.

I have a C# program for .NET Core. I am retrieving the assembly version using:

            <TextBlock xmlns:ref = "clr-namespace:System.Reflection;assembly=mscorlib">
            <TextBlock.Text>
                <Binding Path="Version">
                    <Binding.Source>
                        <ObjectDataProvider MethodName="GetName">
                            <ObjectDataProvider.ObjectInstance>
                                <ObjectDataProvider MethodName="GetExecutingAssembly" ObjectType="{x:Type ref:Assembly}" />
                            </ObjectDataProvider.ObjectInstance>
                        </ObjectDataProvider>
                    </Binding.Source>
                </Binding>
            </TextBlock.Text>
        </TextBlock>

I don't have the assembly version defined in AssemblyInfo.cs, but in Properties | Package I have Assembly Version, Package Version, and Assembly File Version all set to 1.0.0.0. The program is showing the version as 4.0.0.0. Where is it getting that version number? Is there any way to change that version number? (I assume I could override it in AssemblyInfo.cs - not tried that yet, but I don't like the idea of two potentially conflicting version numbers floating around.)

Note that the suggested existing answer does not answer my question, because the file that answer references contains the version number I have specified (1.0.0.0), not the surprising 4.0.0.0 the program is finding, so it is not the source of the version number and is not the answer to my question.

digitig
  • 1,989
  • 3
  • 25
  • 45
  • 1
    Why not take a look? Print the assembly's name or location instead of its version. Note that Xaml does funky stuff at runtime, so chances are the executing assembly is some WPF assembly. You'd be better off getting your assembly using `typeof(SomeTypeOfYours).Assembly` – canton7 Jun 27 '20 at 17:09
  • Have you checked "assembly info" in the "application" tab in the project properties? – Gusman Jun 27 '20 at 17:11
  • I can't see anything about "assembly info" in the "application" tab in the project properties. – digitig Jun 29 '20 at 02:23

0 Answers0