Skip to content

FileLoadException on IServiceCollection.AddReact() #800

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

Closed
TomGroeneboer opened this issue Aug 5, 2015 · 18 comments
Closed

FileLoadException on IServiceCollection.AddReact() #800

TomGroeneboer opened this issue Aug 5, 2015 · 18 comments

Comments

@TomGroeneboer
Copy link

Hi guys,

I've encountered an issue when adding React to a project. If I try to do services.AddReact() in the ConfigureServices method in the Startup class it throws a FileLoadExeption with the following details:
Could not load file or assembly 'React, Version=1.5.0.0, Culture=neutral, PublicKeyToken=9aed67b161f7db78' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)

Does someone know why this happens and how I can resolve it?

I'm running CLR-x86-beta6 in Visual Studio 2015.

Thanks!

@davidfowl
Copy link
Member

That's a good question. Do you have repro steps?

@TomGroeneboer
Copy link
Author

Just create an empty application with ASP.NET 5, add React following these steps.
Note: The services.UseRequestServices() doesn't work, I think it's depricated?

If you try to run the application it comes up with the error :(

@davidfowl
Copy link
Member

Those instructions are based on very old versions of ASP.NET 5. Have you contacted them to ask if they have newer versions that are compatible with newer betas of ASP.NET 5.

@TomGroeneboer
Copy link
Author

There seems to be an update on NuGet but I can't download it in VS, it only states that version 1.5.3 (and lower) is available...

//// update:
I managed to install version 1.5.4, but it still gives me the FileLoadException...

@Daniel15
Copy link
Contributor

Bumping this because I just got another report of it (also see reactjs/React.NET#153). The exception looks like the following:


System.IO.FileLoadException was unhandled by user code
FileName=React, Version=1.5.0.0, Culture=neutral, PublicKeyToken=9aed67b161f7db78
FusionLog=""
HResult=-2146234300
Message=Could not load file or assembly 'React, Version=1.5.0.0, Culture=neutral, PublicKeyToken=9aed67b161f7db78' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
Source=React.AspNet
StackTrace:
at React.AspNet.ReactServiceCollectionExtensions.AddReact(IServiceCollection services)


The strange thing is that the "React" assembly is strong-named. React.AspNet has a dependency on React.Core which contains React.dll, and I've verified that the latest version does indeed have the correct strong name. Note that ReactJS.NET does not support .NET Core at the moment, so this is only using dnx451.

I haven't been able to replicate the issue myself, everything works as expected for me 😟

Any ideas what's going on here?

Those instructions are based on very old versions of ASP.NET 5. Have you contacted them to ask if they have newer versions that are compatible with newer betas of ASP.NET 5.

The latest version of ReactJS.NET was built against beta6, I'll release an update for beta7 soon. The instructions were outdated but I updated them a while ago.

@davidfowl
Copy link
Member

If you could provide a sample application that has the error that would be great. Can one of your users provide that info?

@Daniel15
Copy link
Contributor

The two people that have reported it so far are @TomGroeneboer (who originally reported this issue) and @jongalloway (who reported it earlier today).

@jongalloway are you able to provide a sample app that exhibits the issue?

@jongalloway
Copy link
Contributor

Repro is here: https://github.com/jongalloway/react-js-net-repro

All I did was:

  1. File / New / MVC 6 (beta7)
  2. Follow the steps here http://reactjs.net/getting-started/aspnet5.html
  3. Run

@Daniel15
Copy link
Contributor

Ahh, I see. The issue is that your web project is called "React", but the core ReactJS.NET assembly is also called "React" 😆 I think the assembly loader gets confused and tries to load your site's assembly rather than the ReactJS.NET assembly. This fails because the assembly React.AspNet referenced at build time was strongly-named, and the strong name doesn't match. If I rename your project from "React" to "Reactizzle", I don't get the strong typing error any more (I do get a different unrelated error, which is because the latest release of ReactJS.NET was build against beta6 rather than beta7. The latest master version does support beta 7).

I tried the same thing with ASP.NET 4.5 + MVC 5, and the error is the one I would have expected: "Could not load file or assembly 'React, Version=1.5.0.0, Culture=neutral, PublicKeyToken=9aed67b161f7db78' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. " In this case the assembly bind log shows more details that help to debug the issue:

LOG: Attempting download of new URL file:///c:/users/danlo/documents/visual studio 2015/Projects/ReactBug/React/bin/React.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version

It seems like ASP.NET 5 still tries to load the assembly even though the version number doesn't match, resulting in a more confusing error message.

@davidfowl
Copy link
Member

We had the same problems a long time ago in signalr, then we called it Microsoft.AspNet.SignalR

@Daniel15
Copy link
Contributor

@davidfowl - It may be an edge case, but can the loader guard against this somehow (a referenced assembly having the same name as the site itself)?

@davidfowl
Copy link
Member

We don't look at strong names when loading assemblies. We could probably fail if 2 things have the same name in the graph but it's not something we're going to do in the short term.

@jjkopmels
Copy link

Hi Guys,

this is still not working on my end, freshly installed vs2015, running beta7, empty new solution, mvc6 project, followed the instructions here http://reactjs.net/getting-started/aspnet5.html, run the project and getting the same error.... the error does not occur when cloning the git repo to my local disk, building it and then opening and running the mvc6 demo inside vs2015.... what config thingy am i missing here?

BTW: none of the items, solution or project are called anything like react....

@Daniel15
Copy link
Contributor

@jjkopmels Can you please provide a full stack trace of the exception?

@jjkopmels
Copy link

@Daniel15 sure:

System.IO.FileNotFoundException was unhandled by user code
FileName=Microsoft.Framework.Runtime.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
FusionLog==== Pre-bind state information ===
LOG: DisplayName = Microsoft.Framework.Runtime.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Users/jan/.dnx/runtimes/dnx-clr-win-x86.1.0.0-beta7/bin
LOG: Initial PrivatePath = NULL

Calling assembly : (Unknown).

LOG: This bind starts in default load context.
LOG: Using application configuration file: c:\Users\jan\documents\visual studio 2015\Projects\testert\src\testert\wwwroot\Web.config
LOG: Using host configuration file: C:\Users\jan\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/jan/.dnx/runtimes/dnx-clr-win-x86.1.0.0-beta7/bin/Microsoft.Framework.Runtime.Abstractions.DLL.
LOG: Attempting download of new URL file:///C:/Users/jan/.dnx/runtimes/dnx-clr-win-x86.1.0.0-beta7/bin/Microsoft.Framework.Runtime.Abstractions/Microsoft.Framework.Runtime.Abstractions.DLL.
LOG: Attempting download of new URL file:///C:/Users/jan/.dnx/runtimes/dnx-clr-win-x86.1.0.0-beta7/bin/Microsoft.Framework.Runtime.Abstractions.EXE.
LOG: Attempting download of new URL file:///C:/Users/jan/.dnx/runtimes/dnx-clr-win-x86.1.0.0-beta7/bin/Microsoft.Framework.Runtime.Abstractions/Microsoft.Framework.Runtime.Abstractions.EXE.

HResult=-2147024894
Message=Could not load file or assembly 'Microsoft.Framework.Runtime.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Source=React.AspNet
StackTrace:
at React.AspNet.ReactBuilderExtensions.UseReact(IApplicationBuilder app, Action`1 configure, JsxFileOptions fileOptions)
at testert.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in C:\Users\jan\Documents\Visual Studio 2015\Projects\testert\src\testert\Startup.cs:line 112
InnerException:

@Daniel15
Copy link
Contributor

@jjkopmels That's a different error, it's because the current release version of ReactJS.NET only supports beta 6. The version in the repo supports beta 7 but you need to build it yourself at the moment. I'll post a beta 7 update soon.

@Daniel15
Copy link
Contributor

I just uploaded ReactJS.NET 1.5.5 which supports beta 7 :)

@kilanny
Copy link

kilanny commented Jun 6, 2016

Turned out I added reference (normal) while should be COMReference instead in project file. Very strange problem.

Find out the latest word revealed by God for humankind guidance ! Read Quran now http://quran.com/25

ryanbrandenburg pushed a commit that referenced this issue Nov 19, 2018
…master

[automated] Merge branch 'release/2.2' => 'master'
natemcmaster pushed a commit that referenced this issue Nov 20, 2018
@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants