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

bolero-app template using Bolero.dll (0.15.18) throws could not load Elmish 3.1.0.0 dll exception #180

Closed
Arlorean opened this issue Sep 16, 2020 · 9 comments

Comments

@Arlorean
Copy link

I ran the getting started commands with the latest .NET Core SDK installed (3.1.402) on Windows 10:

dotnet new -i Bolero.Templates
dotnet new bolero-app -o MyApp
cd MyApp
dotnet run -p src/MyApp.Server

When I navigate to http://localhost:5000 I get this error in the console window:

PS C:\Users\AdamDavidson\source\repos\MyApp> dotnet run -p src/MyApp.Server
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using 'C:\Users\AdamDavidson\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
Hosting environment: Development
Content root path: C:\Users\AdamDavidson\source\repos\MyApp\src\MyApp.Server
Now listening on: https://localhost:5001
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://localhost:5000/
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint '/_Host'
info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[3]
      Route matched with {page = "/_Host"}. Executing page /_Host
info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[103]
      Executing an implicit handler method - ModelState is Valid
info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[104]
      Executed an implicit handler method, returned result Microsoft.AspNetCore.Mvc.RazorPages.PageResult.
info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[4]
      Executed page /_Host in 21.9843ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint '/_Host'
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HM2Q8PGCGTVF", Request id "0HM2Q8PGCGTVF:00000001": An unhandled exception was thrown by the application.
System.IO.FileLoadException: Could not load file or assembly 'Elmish, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'Elmish, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null'
   at MyApp.Server.Pages__Host.<ExecuteAsync>b__8_1()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at MyApp.Server.Pages__Host.<ExecuteAsync>b__8_1()
   at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync()
   at MyApp.Server.Pages__Host.ExecuteAsync()
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)


info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 6011.3861ms 500

Here is the information from dotnet --info showing the platform, sdks, frameworks installed etc.:

PS C:\Users\AdamDavidson\source\repos\MyApp> dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.402
 Commit:    9b5de826fd

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.402\

Host (useful for support):
  Version: 3.1.8
  Commit:  9c1330dedd

.NET Core SDKs installed:
  2.1.700 [C:\Program Files\dotnet\sdk]
  3.1.201 [C:\Program Files\dotnet\sdk]
  3.1.402 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

Looking at Bolero.dll (0.15.18) in dotPeek show it has a dependency on Elmish 3.1.0.0 but the package only mentions Elmish 3.0.0.0 which might be why it's not finding the dll that Bolero.dll expects. When I add Elmish 3.1.0.0 as a nuget package explictly I get a different error, so I've not yet found a workaround:

System.MissingMethodException: 'Method not found: 'Void Elmish.Program`4..ctor(Microsoft.FSharp.Core.FSharpFunc`2<!0,System.Tuple`2<!1,Microsoft.FSharp.Collections.FSharpList`1<Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.FSharpFunc`2<!2,Microsoft.FSharp.Core.Unit>,Microsoft.FSharp.Core.Unit>>>>, Microsoft.FSharp.Core.FSharpFunc`2<!2,Microsoft.FSharp.Core.FSharpFunc`2<!1,System.Tuple`2<!1,Microsoft.FSharp.Collections.FSharpList`1<Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.FSharpFunc`2<!2,Microsoft.FSharp.Core.Unit>,Microsoft.FSharp.Core.Unit>>>>>, Microsoft.FSharp.Core.FSharpFunc`2<!1,Microsoft.FSharp.Collections.FSharpList`1<Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.FSharpFunc`2<!2,Microsoft.FSharp.Core.Unit>,Microsoft.FSharp.Core.Unit>>>, Microsoft.FSharp.Core.FSharpFunc`2<!1,Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.FSharpFunc`2<!2,Microsoft.FSharp.Core.Unit>,!3>>, Microsoft.FSharp.Core.FSharpFunc`2<!1,Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.FSharpFunc`2<!2,Microsoft.FSharp.Core.Unit>,Microsoft.FSharp.Core.Unit>>, Microsoft.FSharp.Core.FSharpFunc`2<System.Tuple`2<System.String,System.Exception>,Microsoft.FSharp.Core.Unit>)'.'
@davedawkins
Copy link

davedawkins commented Sep 18, 2020

I tried installing 3.1.300 explicitly and get the same issue. It seems to be independent of the SDK version

I've tried to get this working on a variety of platforms (Windows 10, Windows WSL Ubuntu-18.04, and Ubuntu-20.04 on VirtualBox). It seems any non-Mac target I try gives the same issue with the Elmish.dll. I've also tried checking out Bolero, TemplateHosting and Elmish and building them locally, and then building the bolero template against them, with no success.

This does all work on my macbook, where I have 3.1.301 and 3.1.302 installed.

% uname -a
Darwin davebook.local 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64

david@davebook Bolero % dotnet --list-runtimes
Microsoft.AspNetCore.App 3.1.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.20 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

david@davebook Bolero % dotnet --list-sdks    
3.1.301 [/usr/local/share/dotnet/sdk]
3.1.302 [/usr/local/share/dotnet/sdk]

I'm out of ideas for today for a Windows-based platform

fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HM2RQ6PE4PS7", Request id "0HM2RQ6PE4PS7:00000001": An unhandled exception was thrown by the application.
System.IO.FileLoadException: Could not load file or assembly 'Elmish, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'Elmish, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null'
   at web3d.Server.Pages__Host.<ExecuteAsync>b__8_1()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at web3d.Server.Pages__Host.<ExecuteAsync>b__8_1()
   at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync()
   at web3d.Server.Pages__Host.ExecuteAsync()

@naartjie
Copy link
Contributor

Same issue here.

I got it working (on a Mac):

dotnet new -i Bolero.Templates

# disable hot reload
dotnet new bolero-app --hotreload=false -o MyApp

# install Elmish 3.1.0.0
cd MyApp/src/MyApp.Client
dotnet add package Elmish --version 3.1.0.0
cd ../MyApp.Server
dotnet add package Elmish --version 3.1.0.0

# start the server
dotnet run

If you have installed it with Hot Reload enabled already, you can fix it by commenting out the last line in Main.fs:

    override this.Program =
        let bookService = this.Remote<BookService>()
        let update = update bookService
        Program.mkProgram (fun _ -> initModel, Cmd.ofMsg GetSignedInAs) update view
        |> Program.withRouter router
// #if DEBUG
//         |> Program.withHotReload
// #endif

@davedawkins
Copy link

@naartjie THANK YOU!
I was very close to something like that (disabled hot reload, referenced Elmish 3.1.0.0 explicitly, but not from Client).

This workaround works for Windows 10. Thank you again!

@naartjie
Copy link
Contributor

Cool @davedawkins, I'm glad that works on Windows too.

I had a go at a PR in #181, but not sure that's all that's needed to fix the dependency.

Also with hot reloading, not sure what is broken there. Maybe someone else reading this knows what's up there.

@Tarmil
Copy link
Member

Tarmil commented Sep 19, 2020

This is fixed in Bolero 0.15.23 / Bolero.HotReload 0.15.4. Thanks everyone for the report, investigation and PR!

@davedawkins
Copy link

What a great response. Thanks everyone, very much appreciated

@naartjie
Copy link
Contributor

After updating the template and running dotnet new bolero-app -o MyApp, I am getting a different error now:
(Bolero 0.15.23 and Bolero.HotReload 0.15.4)

Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.1.8.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.1.8.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

@Arlorean
Copy link
Author

Arlorean commented Sep 20, 2020 via email

@naartjie
Copy link
Contributor

Thanks @Arlorean!! Updating to 3.1.8 did the trick 🙌

I'm up and running on a vanilla dotnet new bolero-app. Awesomeness!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants