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)
13709정성태8/7/20249660닷넷: 2293. C# - safe/unsafe 문맥에 대한 C# 13의 (하위 호환을 깨는) 변화파일 다운로드1
13708정성태8/7/202410276개발 환경 구성: 719. ffmpeg / YoutubeExplode - mp4 동영상 파일로부터 Audio 파일 추출
13707정성태8/6/20249872닷넷: 2292. C# - 자식 프로세스의 출력이 4,096보다 많은 경우 Process.WaitForExit 호출 시 hang 현상파일 다운로드1
13706정성태8/5/20249482개발 환경 구성: 718. Hyper-V - 리눅스 VM에 새로운 디스크 추가
13705정성태8/4/20249739닷넷: 2291. C# 13 - (5) params 인자 타입으로 컬렉션 허용 [2]파일 다운로드1
13704정성태8/2/202411040닷넷: 2290. C# - 간이 dotnet-dump 프로그램 만들기파일 다운로드1
13703정성태8/1/20249000닷넷: 2289. "dotnet-dump ps" 명령어가 닷넷 프로세스를 찾는 방법
13702정성태7/31/202410241닷넷: 2288. Collection 식을 지원하는 사용자 정의 타입을 CollectionBuilder 특성으로 성능 보완파일 다운로드1
13701정성태7/30/202410750닷넷: 2287. C# 13 - (4) Indexer를 이용한 개체 초기화 구문에서 System.Index 연산자 허용파일 다운로드1
13700정성태7/29/202410942디버깅 기술: 200. DLL Export/Import의 Hint 의미
13699정성태7/27/202410817닷넷: 2286. C# 13 - (3) Monitor를 대체할 Lock 타입파일 다운로드1
13698정성태7/27/202410479닷넷: 2285. C# - async 메서드에서의 System.Threading.Lock 잠금 처리파일 다운로드1
13697정성태7/26/20249368닷넷: 2284. C# - async 메서드에서의 lock/Monitor.Enter/Exit 잠금 처리파일 다운로드1
13696정성태7/26/20249396오류 유형: 920. dotnet publish - error NETSDK1047: Assets file '...\obj\project.assets.json' doesn't have a target for '...'
13695정성태7/25/20249668닷넷: 2283. C# - Lock / Wait 상태에서도 STA COM 메서드 호출 처리파일 다운로드1
13694정성태7/25/20249719닷넷: 2282. C# - ASP.NET Core Web App의 Request 용량 상한값 (Kestrel, IIS)
13693정성태7/24/20248993개발 환경 구성: 717. Visual Studio - C# 프로젝트에서 레지스트리에 등록하지 않은 COM 개체 참조 및 사용 방법파일 다운로드1
13692정성태7/24/202410381디버깅 기술: 199. Windbg - 리눅스에서 뜬 닷넷 응용 프로그램 덤프 파일에 포함된 DLL의 Export Directory 탐색
13691정성태7/23/20249147디버깅 기술: 198. Windbg - 스레드의 Win32 Message Queue 정보 조회
13690정성태7/23/20248418오류 유형: 919. Visual C++ 리눅스 프로젝트 - error : ‘u8’ was not declared in this scope
13689정성태7/22/202411496디버깅 기술: 197. Windbg - PE 포맷의 Export Directory 탐색
13688정성태7/21/20249347닷넷: 2281. C# - Lock / Wait 상태에서도 일부 Win32 메시지 처리파일 다운로드1
13687정성태7/19/202410582닷넷: 2280. C# - PostThreadMessage로 보낸 메시지를 Windows Forms에서 수신하는 방법파일 다운로드1
13686정성태7/19/20249984오류 유형: 918. Visual Studio - ATL Simple Object 추가 시 error C2065: 'IDR_...': undeclared identifier
13685정성태7/19/20249675스크립트: 66. Windows 디렉터리 경로를 WSL의 /mnt 포맷으로 구하는 방법 - 두 번째 이야기
13684정성태7/19/202410624닷넷: 2279. C# - 문자열 보간식 사례 (예: 조건 연산자 사용)
1  2  3  4  5  6  7  8  9  10  11  [12]  13  14  15  ...