Unhandled exception: System.NullReferenceException: Object reference not set to an instance of an object.
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- csharp
- Lĩnh vực
- devtools, observability
Hướng nghiên cứu
Bắt đầu tại dòng 200 của src/Tools/dotnet-counters/CounterMonitor.cs và tái hiện lời gọi dotnet-counters monitor -n ConsoleApp --counters HatCo.Store từ issue trong Visual Studio Package Manager Console. Sử dụng mẫu .NET 8 được cung cấp để theo dõi đường dẫn tham chiếu null, sau đó xác minh rằng việc giám sát bộ đếm HatCo.Store không còn thoát do một ngoại lệ chưa được xử lý.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
I followed the documentation on learn.microsoft.com:
and have trouble to use the dotnet-counters monitor tool in the visual studio package manger console.
I'm getting an Unhandled exception: System.NullReferenceException: Object reference not set to an instance of an object.
PM> dotnet-counters monitor -n ConsoleApp --counters HatCo.Store
dotnet-counters : Unhandled exception: System.NullReferenceException: Object reference not set to an instance of an object.
At line:1 char:1
+ dotnet-counters monitor -n ConsoleApp --counters HatCo.Store
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Unhandled excep...e of an object.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
at Microsoft.Diagnostics.Tools.Counters.CounterMonitor.Monitor(CancellationToken ct, String counters, Int32 processId, Int32
refreshInterval, String name, String diagnosticPort, Boolean resumeRuntime, Int32 maxHistograms, Int32 maxTimeSeries, TimeSpan duration,
Boolean showDeltas, String dsrouter) in /_/src/Tools/dotnet-counters/CounterMonitor.cs:line 200
at System.CommandLine.Command.<>c__DisplayClass32_0.<<SetAction>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
PM> dotnet-counters --version
9.0.652701+240cb1ce5bc30594c515206764241d7982e384af
I appreciate any help.
Configuration
Start the following source code in .NET 8.0 and run dotnet-counters in Visual Studio 2022 package manager console
using System.Diagnostics.Metrics;
using Microsoft.Extensions.DependencyInjection;
class Program
{
static void Main(string[] arguments)
{
Console.WriteLine("Press any key to exit");
using ServiceProvider serviceProvider = CreateServiceProvider();
var hatCoMetrics = serviceProvider.GetRequiredService<HatCoMetrics>();
Random random = new();
while (!Console.KeyAvailable)
{
// Pretend our store has a transaction, every 100ms, that sells two size 12 red hats, and one size 19 blue hat.
Thread.Sleep(random.Next() % 5000);
hatCoMetrics.HatsSold(random.Next() % 6, "red", 12);
hatCoMetrics.HatsSold(random.Next() % 6, "blue", 19);
}
}
// Setup a new service provider. This example creates the collection explicitly but you might leverage
// a host or some other application setup code to do this as well.
private static ServiceProvider CreateServiceProvider()
{
ServiceCollection serviceCollection = new();
serviceCollection.AddMetrics();
serviceCollection.AddSingleton<HatCoMetrics>();
return serviceCollection.BuildServiceProvider();
}
}
public class HatCoMetrics
{
private readonly Counter<int> _hatsSold;
public HatCoMetrics(IMeterFactory meterFactory)
{
Meter meter = meterFactory.Create("HatCo.Store");
_hatsSold = meter.CreateCounter<int>("hatco.store.hats_sold");
}
public void HatsSold(int quantity, string color, ushort size)
{
if (quantity == 0) return;
_hatsSold.Add(quantity,
new KeyValuePair<string, object?>("product.color", color),
new KeyValuePair<string, object?>("product.size", size)
);
}
}
- Ngôn ngữ chính
- C++
- Star
- 1.3k
- Fork
- 407
- Merge trung bình
- 21 giờ 5 phút
- Pull request đã merge (30 ngày)
- 78
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dotnet/diagnostics
-
Fix StackAndOtherTests.script line number verification for .NET 11 and Windows x64Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
dotnet/diagnostics#5884 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
dotnet/diagnostics#6225 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
dotnet/diagnostics#6213 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Isolate SOS hosting from other debugger extensions that use managed codeCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
dotnet/diagnostics#6207 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Known Build Error
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 49/100
dotnet/diagnostics#6190 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của dotnet/diagnostics
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
AutoHotkey/AutoHotkey#380 ·
-
documentation
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Lua File: add readWhole()Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
grumpycoders/pcsx-redux#2667 ·
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
google/tensorstore#305 ·