C # project: how to update the referenced version of an assembly
I have a C # project that is referencing a one way assembly. When I try to update a one-way build, the version tag remains the same in the * .csproj file even if I unload / reload the project:
<Reference Include="<myAssembly>, Version=<oldVersion>, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath><myHintPath></HintPath> </Reference>
So my project is trying to reference an older version of the assembly and this throws an exception. It is so painful to manually change all these versions in links, especially if there are many links.
I tried to change some attribute of the link, for example
and return to
, and the link is updated:
<Reference Include="<myAssembly>, Version=<newVersion>, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath><myHintPath></HintPath> </Reference>
Any ideas how to automatically update references if I update the assembly? Please note that when I
link to any assembly of the system, for example , the link is very simple:
<Reference Include="System.Configuration.Install" />
I can manually remove everything from this 3rd party assembly reference, but when I change some attribute it falls back to the complex version and I'm not sure if it's safe.
So how do you update links correctly?
source to share
If you always want to get the latest version of the assembly from the specified path, just avoid the version attribute in the csproj file or set the SpecificVersion to False. SpecificVersion is an optional attribute indicating whether full name matching (including version, culture, and PublicKeyToken) should be performed.
<Reference Include="assemblyNameOnly"> <HintPath>pathToDll</HintPath> </Reference>
But this is not recommended because the new version of the assembly may cause compilation errors, eg. the method signature changes. Instead, it is better to use strong named assemblies and redirect version assemblies using config files.
<Reference Include="assemblyName, Version=Version, Culture=neutral, PublicKeyToken=keyToken, processorArchitecture=MSIL"> <SpecificVersion>True</SpecificVersion> <HintPath>pathToDll</HintPath> </Reference>
Then Runtime will find new assemblies using the described algorithm here
source to share