Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (seongtaejeong at gmail.com)
홈페이지
첨부 파일
 

.NET 8 이상만 지원하는 Microsoft.Data.SqlClient 6.1.0 버전

얼마전 nuget에 Microsoft.Data.SqlClient 6.1.0 버전이 릴리스됐습니다.

Microsoft.Data.SqlClient 6.1.0
; https://www.nuget.org/packages/microsoft.data.sqlclient

지원 범위에 .NET Standard 2.0이 있어,

.NET Standard
; https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0

원칙상 .NET Core 2.0 이상의 환경을 지원한다는 건데요, 그런데 실제로 해보면 .NET 8 미만의 환경에서는,

internal class Program
{
    // .NET 7 이하의 프로젝트
    // Install-Package Microsoft.Data.SqlClient
    static void Main(string[] args)
    {
        SqlCommand cmd = new SqlCommand();
        cmd.Parameters.AddWithValue("@param1", "value1");
    }
}

SqlCommand 타입이 가진 대부분의 필드가 아래의 화면처럼,

sqlclient_null_ref_1.png

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Data.SqlClient.SqlCommand.get_Parameters()
   at ConsoleApp1.Program.Main(String[] args)

null 참조 예외가 발생합니다. 디버깅 시 소스 코드로 들어가 보면 이런 식으로 구성이 되어 있는데,


...[생략]...
public bool EnableOptimizedParameterBinding { get { throw null; } set { } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/Parameters/*'/>
public new Microsoft.Data.SqlClient.SqlParameterCollection Parameters { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/Transaction/*'/>
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(0)]
public new Microsoft.Data.SqlClient.SqlTransaction Transaction { get { throw null; } set { } }
...[생략]...

전형적인 참조 어셈블리의 내용입니다. 확인을 위해 디버깅 상태에서 모듈 창을 열어 DLL 경로를 알아내,

C:\temp\WebApplication1\WebApplication2\bin\Debug\net7.0\Microsoft.Data.SqlClient.dll

파일을 찾아가 보면 크기가 약 78KB인데요, nuget 패키지의 경로를 통해 다른 DLL과 비교하면,

[참조 어셈블리: 약 78KB]
"...nuget_root...\Microsoft.Data.SqlClient\extracted\6.1.0\ref\netstandard2.0\Microsoft.Data.SqlClient.dll"

[구현 어셈블리: 약 2MB]
"...nuget_root...\Microsoft.Data.SqlClient\extracted\6.0.2\runtimes\win\lib\net8.0\Microsoft.Data.SqlClient.dll"

확실히 참조 어셈블리가 맞습니다.




근본적인 원인은 패키지 오류인 듯합니다. 설치된 "microsoft.data.sqlclient.6.1.0.nupkg" 파일을 열어보면, ".\lib\netstandard2.0" 디렉터리에 참조 어셈블리가 들어 있습니다. 유사하게 ".\lib\net462"에는 구현 어셈블리가 들어 있는 것으로 봐서 아마도 패키지를 생성하는 담당자가 실수를 한 것이 아닌가... 싶습니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 8/5/2025]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  4  5  [6]  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13859정성태1/9/20256494디버깅 기술: 215. Windbg - syscall 이후 실행되는 KiSystemCall64 함수 및 SSDT 디버깅
13858정성태1/8/20256794개발 환경 구성: 738. PowerShell - 원격 호출 시 "powershell.exe"가 아닌 "pwsh.exe" 환경으로 명령어를 실행하는 방법
13857정성태1/7/20256944C/C++: 187. Golang - 콘솔 응용 프로그램을 Linux 데몬 서비스를 지원하도록 변경파일 다운로드1
13856정성태1/6/20255286디버깅 기술: 214. Windbg - syscall 단계까지의 Win32 API 호출 (예: Sleep)
13855정성태12/28/20247525오류 유형: 941. Golang - os.StartProcess() 사용 시 오류 정리
13854정성태12/27/20247274C/C++: 186. Golang - 콘솔 응용 프로그램을 NT 서비스를 지원하도록 변경파일 다운로드1
13853정성태12/26/20245850디버깅 기술: 213. Windbg - swapgs 명령어와 (Ring 0 커널 모드의) FS, GS Segment 레지스터
13852정성태12/25/20247458디버깅 기술: 212. Windbg - (Ring 3 사용자 모드의) FS, GS Segment 레지스터파일 다운로드1
13851정성태12/23/20246086디버깅 기술: 211. Windbg - 커널 모드 디버깅 상태에서 사용자 프로그램을 디버깅하는 방법
13850정성태12/23/20247744오류 유형: 940. "Application Information" 서비스를 중지한 경우, "This file does not have an app associated with it for performing this action."
13849정성태12/20/20247727디버깅 기술: 210. Windbg - 논리(가상) 주소를 Segmentation을 거쳐 선형 주소로 변경
13848정성태12/18/20247056디버깅 기술: 209. Windbg로 알아보는 Prototype PTE파일 다운로드2
13847정성태12/18/20246775오류 유형: 939. golang - 빌드 시 "unknown directive: toolchain" 오류 빌드 시 이런 오류가 발생한다면?
13846정성태12/17/20247663디버깅 기술: 208. Windbg로 알아보는 Trans/Soft PTE와 2가지 Page Fault 유형파일 다운로드1
13845정성태12/16/20245967디버깅 기술: 207. Windbg로 알아보는 PTE (_MMPTE)
13844정성태12/14/20248794디버깅 기술: 206. Windbg로 알아보는 PFN (_MMPFN)파일 다운로드1
13843정성태12/13/20246268오류 유형: 938. Docker container 내에서 빌드 시 error MSB3021: Unable to copy file "..." to "...". Access to the path '...' is denied.
13842정성태12/12/20246432디버깅 기술: 205. Windbg - KPCR, KPRCB
13841정성태12/11/20247311오류 유형: 937. error MSB4044: The "ValidateValidArchitecture" task was not given a value for the required parameter "RemoteTarget"
13840정성태12/11/20246300오류 유형: 936. msbuild - Your project file doesn't list 'win' as a "RuntimeIdentifier"
13839정성태12/11/20247648오류 유형: 936. msbuild - error CS1617: Invalid option '12.0' for /langversion. Use '/langversion:?' to list supported values.
13838정성태12/4/20247220오류 유형: 935. Windbg - Breakpoint 0's offset expression evaluation failed.
13837정성태12/3/20248142디버깅 기술: 204. Windbg - 윈도우 핸들 테이블 (3) - Windows 10 이상인 경우
13836정성태12/3/20246143디버깅 기술: 203. Windbg - x64 가상 주소를 물리 주소로 변환 (페이지 크기가 2MB인 경우)
13835정성태12/2/20248123오류 유형: 934. Azure - rm: cannot remove '...': Directory not empty
13834정성태11/29/20248118Windows: 275. C# - CUI 애플리케이션과 Console 윈도우 (Windows 10 미만의 Classic Console 모드인 경우) [1]파일 다운로드1
1  2  3  4  5  [6]  7  8  9  10  11  12  13  14  15  ...