.NET 3.5 C#을 사용하여 모바일 클라이언트에 서비스하는 WCF 웹 서비스가 있습니다. 클라이언트는 서버에 데이터를 보내고 업데이트를 받기 위해이 서비스를 자주 사용합니다. IIS 7.5에 배포 된 서비스로 매일 아침 06시에 재활용하도록 구성되었습니다. 리사이클은 일반적으로 아무렇지도 않게 작동하며 고객은 평소와 같이 서비스를 계속 사용합니다. 그러나 재사용으로 인해 응용 프로그램이 재미있는 상태로 바뀌고 다음과 같이 유형 초기화 오류로 가득 찬 로그를 볼 수있는 몇 가지 사건이있었습니다.IIS 리사이클 이벤트 후 .NET 유형 초기화 예외
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)
at Docobo.Keswick.DbAccess.TableData.DataClasses.GetInfo(Type type)
DataClasses 데이터베이스 테이블 이름을 조회하는 IQToolkit 사용하는 내부 정적 인 클래스입니다 : 뭔가가 성공적으로 DLL을 언로드되지 않은 중복 재활용을하는 동안 발생하는 것처럼 거의이다
internal static class DataClasses
{
private static readonly Dictionary<Type, DataClassInfo> classInfos = new Dictionary<Type, DataClassInfo>();
public static DataClassInfo GetInfo(Type type)
{
DataClassInfo info;
if (!classInfos.TryGetValue(type, out info))
{
// This is not thread-safe, but that's fine.
// If this class is generated more than once it doesn't matter.
info = new DataClassInfo(type);
classInfos[type] = info;
}
return info;
}
}
수동으로 응용 프로그램 풀을 재활용하면 문제가 해결되었습니다. stacktrace에서 static readonly 필드 classInfos이 NULL이 될 수 있지만 어떻게 될 수 있는지 모르겠습니다. 당신이 동시에 사전에 액세스하는 경우가 발생할 수
System.Collections.Generic.Dictionary`2.Insert
거의 유일한 이유는 : 당신이 스택 트레이스에서 볼 수
'type'은 null 일 수 있습니다. – rodrigogq
아니요. 나는 그렇게 생각하지 않습니다. – user3703978