Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init scenario error: 'System.TypeLoadException: Could not load type 'FsToolkit.ErrorHandling.TaskResultCE' #591

Closed
anpin opened this issue Jun 12, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@anpin
Copy link

anpin commented Jun 12, 2023

Hi, I'm unable to run NBomber in NUnit F# project if it has dependency on FsToolkit.ErrorHandling.TaskResult package. The error message is:

18:18:22 [ERR] Init scenario error: 'System.TypeLoadException: Could not load type 
'FsToolkit.ErrorHandling.TaskResultCE' from assembly 
'FsToolkit.ErrorHandling.TaskResult, Version=4.6.0.0, Culture=neutral, 
PublicKeyToken=null'.
   at NBomber.DomainServices.TestHost.WorkerPlugins.init@16-1.Invoke(Unit 
unitVar)
   at Ply.TplPrimitives.tryWith[u](FSharpFunc`2 continuation, FSharpFunc`2 
catch)'

here is quick fsi repro

#r "nuget: NBomber"
#r "nuget: FsToolkit.ErrorHandling.TaskResult"
#r "nuget: Ply"
open System
open System.Threading.Tasks
open NBomber.FSharp
open NBomber.Contracts
open FsToolkit.ErrorHandling
open Serilog.Events

Scenario.create("load-test", fun ctx -> task {
    do! Task.Delay(100)
    return Response.ok ()
})
|> Scenario.withoutWarmUp
|> Scenario.withLoadSimulations [ KeepConstant(1, TimeSpan.FromSeconds(10)) ]
|> NBomberRunner.registerScenario
|> NBomberRunner.withMinimumLogLevel LogEventLevel.Debug
|> NBomberRunner.run
@anpin
Copy link
Author

anpin commented Jun 13, 2023

related to #576

@anpin
Copy link
Author

anpin commented Jun 13, 2023

I have found that simply updating FsToolkit.ErrorHandling.TaskResult to latest version didn't fix the error. I had to also change target framework to netstandard 2.1 (my test project is targeting .net7.0)

@AntyaDev
Copy link
Contributor

Hi @anpin
What version of FsToolkit.ErrorHandling.TaskResult did you used?
Try 2.13.0

@anpin
Copy link
Author

anpin commented Jun 13, 2023

I have to use latest version 4.6.0 as it is transient dependency from another nuget

@AntyaDev
Copy link
Contributor

AntyaDev commented Jun 13, 2023

It may not work. I never tested with version 4.x

@AntyaDev
Copy link
Contributor

Hi @anpin
please try this version
https://www.nuget.org/packages/NBomber/5.2.1-beta.0

@anpin
Copy link
Author

anpin commented Aug 17, 2023

Hi @anpin please try this version https://www.nuget.org/packages/NBomber/5.2.1-beta.0

Thanks, it works!

dotnet fsi ./nbomber.fsx
  _   _   ____                        _                       ____
 | \ | | | __ )    ___    _ __ ___   | |__     ___   _ __    | ___|
 |  \| | |  _ \   / _ \  | '_ ` _ \  | '_ \   / _ \ | '__|   |___ \
 | |\  | | |_) | | (_) | | | | | | | | |_) | |  __/ | |       ___) |
 |_| \_| |____/   \___/  |_| |_| |_| |_.__/   \___| |_|      |____/

12:27:08 [INF] NBomber "5.2.1" started a new session: "2023-08-17_08.27.37_session_97b4bc42"
12:27:08 [INF] NBomber started as single node
12:27:08 [INF] License validation....
12:27:08 [WRN] THIS VERSION IS FREE ONLY FOR PERSONAL USE. You can't use it for an organization.
12:27:08 [INF] Reports folder: "/home/a/.nuget/packages/nbomber/5.2.1-beta.0/lib/netstandard2.1/reports/2023-08-17_08.27.37_session_97b4bc42"
12:27:08 [INF] Plugins: no plugins were loaded
12:27:08 [INF] Reporting sinks: no reporting sinks were loaded
12:27:08 [INF] Starting init...
12:27:08 [INF] Target scenarios: "load-test"
12:27:08 [INF] Init finished
12:27:08 [INF] Starting bombing...
12:27:22 [INF] Stopping scenarios...
12:27:22 [INF] Calculating final statistics...

───────────────────────────────────────────────────────────────────────────────────────────────────── test info ─────────────────────────────────────────────────────────────────────────────────────────────────────

test suite: nbomber_default_test_suite_name
test name: nbomber_default_test_name
session id: 2023-08-17_08.27.37_session_97b4bc42

────────────────────────────────────────────────────────────────────────────────────────────────── scenario stats ───────────────────────────────────────────────────────────────────────────────────────────────────

scenario: load-test
  - ok count: 94
  - fail count: 0
  - all data: 0 MB
  - duration: 00:00:10

load simulations:
  - keep_constant, copies: 1, during: 00:00:10

┌────────────────────┬────────────────────────────────────────────────────────┐
│               step │ ok stats                                               │
├────────────────────┼────────────────────────────────────────────────────────┤
│               name │ global information                                     │
│      request count │ all = 94, ok = 94, RPS = 9.4                           │
│            latency │ min = 99.4, mean = 100.43, max = 106.57, StdDev = 0.79 │
│ latency percentile │ p50 = 100.42, p75 = 100.8, p95 = 101.12, p99 = 101.25  │
└────────────────────┴────────────────────────────────────────────────────────┘


12:27:22 [INF] Reports saved in folder: "/home/a/nbomber-repro/reports/2023-08-17_08.27.37_session_97b4bc42"
12:27:22 [WRN] THIS VERSION IS FREE ONLY FOR PERSONAL USE. You can't use it for an organization.

@anpin anpin closed this as completed Aug 17, 2023
@AntyaDev AntyaDev added bug Something isn't working 5.2.1 labels Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants