I am using VS2010 and I tried to add a few assemblies from local hard disk to my C# project through file reference. Peeking into the csproj
file, I found sometimes the file reference appears as
<Reference Include="name">
However sometimes it appears as
<Reference Include="name, Version=xxx, Culture=neutral, processorArchitecture=MSIL">
What could cause the difference?
Inspired by k3b's answer, I did another test. I created a new class library project.
Add a file reference. The initial value of Specific Version in Properties pane is False. The csproj
file look like
<Reference Include="Name"> <HintPath>...</HintPath> </Reference>
Change Specific Version in Properties pane to True. VS adds version in the Include
attribute.
<Reference Include="Name, Version=..."> <HintPath>...</HintPath> </Reference>
Change Specific Version in Properties pane to False again. VS adds a child element SpecificVersion
.
<Reference Include="Name, Version=..."> <HintPath>...</HintPath> <SpecificVersion>False</SpecificVersion> </Reference>
So it seems that the rule is:
SpecificVersion
child element, the file assembly is configured to be Specific VersionSpecificVersion
child element is only appended with value False.One thing I still do not understand:
In the Project Designer, click the References tab. Click the Add button to open the Add Reference dialog box. In the Add Reference dialog box, select the tab indicating the type of component you want to reference. Select the components you want to reference, and then click OK.
Reference assemblies are usually distributed with the Software Development Kit (SDK) of a particular platform or library. Using a reference assembly enables developers to build programs that target a specific library version without having the full implementation assembly for that version.
Which reference-type you get depends on how you link the assembly.
there you find a boolean flag "specific Version"
(I only have a german-vs2010 so the english translation for the german "Spezifische Version" may be slightly different)
[update]
I tried the following using vcs2010-express german
add reference with default SpecificVersion=False : no version
<Reference Include="Castle.Core"> <HintPath>..\..\..\lib\fluentNHibernate\Castle.Core.dll</HintPath> </Reference>
modified reference: SpecificVersion=True : added version
<Reference Include="Castle.Core, Version=2.5.1.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL"> <HintPath>..\..\..\lib\fluentNHibernate\Castle.Core.dll</HintPath> </Reference>
modified reference again: SpecificVersion=False : version remains and new element SpecificVersion
<Reference Include="Castle.Core, Version=2.5.1.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL"> <HintPath>..\..\..\lib\fluentNHibernate\Castle.Core.dll</HintPath> <SpecificVersion>False</SpecificVersion> </Reference>
It seems that the specific version is remembered but ignorede because of <SpecificVersion>False</SpecificVersion>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With