I have created Class Library using Visual Studio 2022 community v 17.9.6 TragetFramework 8 project file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>.0
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>AchieveResource</AssemblyName>
<RootNamespace>Achieve.AchieveResource</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.11.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="Achieve.Common">
<HintPath>..\Achieve.Common\bin\Debug\net8.0\Achieve.Common.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Update="AchieveResource1.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>AchieveResource1.resx</DependentUpon>
</Compile>
</ItemGroup>
</Project>
A console application is referencing this dll and when one of the static methods in the library is called, it throws the following error, although the project is referencing
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" /> it complains that Microsoft.Data.SqlClient version 5.0.0.0 not found.
I got a similar error when using System.Data.SQLClient 4.8.6 and the error was that System.Data.SQLClient version 4.4.0 could not be found.
Any idea? Thanks
FileNotFoundException: Could not load file or assembly 'Microsoft.Data.SqlClient, Version=5.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5'. The system cannot find the file specified.
System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'Achieve.AchieveReserouce.ConnectionStrings' threw an exception.
Source=AchieveResource
StackTrace:
at Achieve.AchieveReserouce.ConnectionStrings.GetEnterpriseConnectionString()
at Program.<Main>$(String[] args) in C:\Dev\Achieve\2022Projects\ConsoleApp1\Program.cs:line 4
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
FileNotFoundException: Could not load file or assembly 'Microsoft.Data.SqlClient, Version=5.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5'. The system cannot find the file specified.
The line in the console application is
OUConstr = Achieve.AchieveReserouce.ConnectionStrings.GetConnectionSringForOU(1004);