我在我想調試的32位Windows Server 2003計算機上安裝了C#windows服務。如何使用windbg查看c#變量
我的問題是,一個日誌文件中的錯誤消息告訴我下面的:
System.NullReferenceException: Object reference not set to an instance of an object.
at VideoProcessor.ResetCameraProperties(DataServiceObject dso)
at VideoProcessor.AddServer(DataServiceObject dso)
at VideoProcessor.LoadServers()
at VideoProcessor.Start()
atVideoServerComponent.Connect()
的功能ResetCameraProperties實際的代碼:
protected void ResetCameraProperties(DataServiceObject dso)
{
// Find the CameraType.
//Type videoCameraType = TypeManager.Instance["XFire.Common.VideoObjects.VideoServer"];
if (_videoCameraType == null) return;
//Load cameras from the Data Service Layer
string whereClause = "ServerID = ?";
object[] args = new object[] { dso["ObjectID"] };
IDataServiceCollection videoCameraDsoCollection = ClientServerConnection.Instance.FindCollection(_videoCameraType, whereClause, args, null, CollectionOptions.FilterByPartitionResponsibility) as IDataServiceCollection;
if (videoCameraDsoCollection == null || 0 == videoCameraDsoCollection.Count)
return;
videoCameraDsoCollection.LoadContainerOnEnumeration = false;
foreach (DataServiceObject camera in videoCameraDsoCollection)
{
if (!(bool)dso[RecorderKey.Online] && (int)dso[RecorderKey.VideoServerAlarm] == (int)VideoServerComponent.GetVideoServerAlarm("Offline"))
{
// If the server is disconnected, then we know everything should be offline.
camera[CameraKey.VideoCameraAlarm] = VideoServerComponent.GetEnumValueOfType("XFire.Common.VideoObjectDefinitions.VideoCameraAlarm", "Unknown");
camera[CameraKey.Videoloss] = true;
}
else if ((bool)dso[RecorderKey.Online] && (int)dso[RecorderKey.VideoServerAlarm] == (int)VideoServerComponent.GetVideoServerAlarm("Online"))
{
camera[CameraKey.VideoCameraAlarm] = VideoServerComponent.GetEnumValueOfType("XFire.Common.VideoObjectDefinitions.VideoCameraAlarm", "Normal");
camera[CameraKey.Videoloss] = false;
}
// Save the camera.
ServerResult result = ClientServerConnection.Instance.PersistObject(camera, null);
if (result.Fault != null)
{
if (VideoTrace.TraceError) Trace.WriteLine(result.Fault.Message);
}
}
- 我已經打開的WinDbg和沒有文件 - >附加到進程
- 我在功能設置使用上述這裏列出的步驟斷點:http://blogs.msdn.com/b/alejacma/archive/2009/07/13/managed-debugging-with-windbg-preparing-the-environment.aspx
當斷點被擊中我走上前使用F10,但我看到的是這樣的:
設置斷點:BP 05A0A260 [,視頻處理器。 ResetCameraProperties *(XFire.Common.DataServiceLayer.DataServiceObject)] 添加未決斷點... ** 0:024>克 DriverWindowsService.OnStop服務停止... 斷點0擊中 EAX = 00000001 EBX = 00902870 ecx = 00a1e020 edx = 01066e78 esi = 00affb48 edi = 01066e78 eip = 05a0a260 esp = 0674e68c ebp = 0674e6b0 iopl = 0 nv up ei pl nz na po nc cs = 001b ss = 0023 ds = 0023 es = 0023 fs = 003b GS = 0000 EFL = 00000202 05a0a260 55推EBP 0:024>點 EAX = 00000001 EBX = 00902870 ECX = 00a1e020 EDX = 01066e78 ESI = 00affb48 EDI = 0106 6e78 eip = 05a0a261 esp = 0674e688 ebp = 0674e6b0 iopl = 0 nv up ei pl nz na po nc cs = 001b ss = 0023 ds = 0023 es = 0023 fs = 003b gs = 0000 efl = 00000202 05a0a261 8bec mov ebp,尤 0:024>點 EAX = 00000001 EBX = 00902870 ECX = 00a1e020 EDX = 01066e78 ESI = 00affb48 EDI = 01066e78 EIP = 05a0a263 ESP = 0674e688 EBP = 0674e688 IOPL = 0 NV向上EI PL NZ NA PO NC CS = 001B SS = 0023 DS = 0023 ES = 0023 FS = 003B GS = 0000 EFL = 00000202 05a0a263 57推EDI
這意味着目前nothign到我(我是一個WinDBG的新手)
- 我對窗口服務(我從Visual Studio調試輸出文件夾了),並在一個文件夾ç複製ITTO我的目標機器PDB文件:\符號。
- 在WinDbg中我做了文件 - >符號文件路徑並將其設置爲我複製此PDB文件的位置。我的符號路徑如下: C:\ symcache; C:\符號; SRV * C:\ * symcache http://msdl.microsoft.com/download/symbols
在WinDbg中我做了視圖 - >觀看和我的名字輸入一個變量在上面的函數中(videoCameraType)。但我得到了以下錯誤:
* * * * 要麼你指定一個不合格的符號,或者您的調試器 *沒有完全的符號信息。不合格符號* 分辨率默認爲關閉。請要麼指定 *完全合格的符號模塊!符號名稱,或鍵入」 .symopt- 100" 使分辨率不合格符號* 。需要注意的是 *能夠在符號路徑* 服務器共享網絡符號不合格的符號分辨率可能導致調試器 *似乎掛起了很長一段時間,當一個不正確的* 符號名稱已鍵入或網絡符號服務器已關閉。 ** 對於一些命令才能正常工作,你的符號路徑 *必須指向.PDB有完整的類型信息的文件。 * *某些.pdb文件(如公共操作系統符號)不* 包含所需信息。聯繫該 *爲您提供了這些符號,如果你需要這個命令* 工作組。 ** *類型引用:_videoCameraType * * *
如何查看變量,通常看到什麼是在我的代碼怎麼回事??? ? 我也有Windows服務的源代碼,如果這有什麼幫助。
感謝