BenchmarkDotNet icon indicating copy to clipboard operation
BenchmarkDotNet copied to clipboard

how to debug reflection error

Open MarshalOfficial opened this issue 3 years ago • 4 comments
trafficstars

Hi there, I got this error when running my benchmark console application:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.NotSupportedException: Unknown Acknowledgment: cknowledgment
   at BenchmarkDotNet.Engines.ConsoleHost.SendSignal(HostSignal hostSignal)
   at BenchmarkDotNet.Engines.HostExtensions.BeforeMainRun(IHost host)
   at BenchmarkDotNet.Engines.Engine.Run()
   at BenchmarkDotNet.Autogenerated.Runnable_0.Run(IHost host, String benchmarkName) in D:\path\path\path\project-name\bin\Release\net5.0\905bb547-33f1-4501-898b-08ad67d64091\905bb547-33f1-4501-898b-08ad67d64091.notcs:line 169
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at BenchmarkDotNet.Autogenerated.UniqueProgramName.AfterAssemblyLoadingAttached(String[] args) in D:\path\path\path\project-name\bin\Release\net5.0\905bb547-33f1-4501-898b-08ad67d64091\905bb547-33f1-4501-898b-08ad67d64091.notcs:line 51

How can I detect the problem? My code is:

public class GetAccountBalanceBenchmark
    {
        [Benchmark]
        public async Task RUN() 
        {
            var _ = await Core.Sdk.GetAccountBalance(new SDK.Models.GetAccountBalanceModel { Id = "10", IdType = Codec.IdType.ACCOUNT });            
        }
    }

MarshalOfficial avatar Mar 06 '22 10:03 MarshalOfficial

Hi @MarshalOfficial

Is there any chance that your benchmark is printing anything to the console?

Which BDN, .NET and OS versions are you using?

adamsitnik avatar Mar 07 '22 15:03 adamsitnik

Hi @adamsitnik

In the case of console logs, it prints starting benchmark then build in release mode and tried to run my project, but after that, it makes this reflection error.

My project is a console application via dotnet 5, my OS is Win10 and IDE is VS.

Also, the project is about connecting to an Aeron server via a Java media driver and communicating with that. In my source code, I have an Init function that tries to write an embedded Jar file from the project's resource and then starts some threads to run that jar file via a batch file and connect to Aeron context and send/receive messages.

MarshalOfficial avatar Mar 07 '22 16:03 MarshalOfficial

@MarshalOfficial Sorry for not making myself clear, is your code (what you are benchmarking, not BenchmarkDotNet itself) printing anything to the console?

Example:

[GlobalSetup]
public void Print() => Console.WriteLine("Setup!");

Which BenchmarkDotNet version are you using?

Are you able to consistently repro this issue?

adamsitnik avatar Mar 07 '22 16:03 adamsitnik

@adamsitnik Thank you for following up

Yes, my project itself logs on the console a lot.

BenchmarkDotNet package version was: 0.13.1 Latest Stable

Unfortunately, I was not able to get a benchmark successfully at all, and it gives the same error every time.

MarshalOfficial avatar Mar 08 '22 08:03 MarshalOfficial

Unfortunately, I was not able to get a benchmark successfully at all, and it gives the same error every time.

#2092 should have fixed this error. You can try our preview version from BDN CI feed:

https://benchmarkdotnet.org/articles/guides/nuget.html#nightly

adamsitnik avatar Oct 05 '22 10:10 adamsitnik