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

"Object reference not set to an instance of an object." produced when using 'Self-contained' AND 'Produce single file' publishing options in net6.0 #291

Open
developarratoutlookdotcom opened this issue Dec 27, 2021 · 2 comments

Comments

@developarratoutlookdotcom
Copy link

Error

I receive the error when trying to run an app 'published' with the following settings:

  • net6.0-windows
  • self-contained
  • win-x64
  • single file
System.NullReferenceException: Object reference not set to an instance of an object.
   at Carter.DependencyContextAssemblyCatalog.GetAssemblies()
   at Carter.CarterExtensions.WireupCarter(IServiceCollection services, DependencyContextAssemblyCatalog assemblyCatalog, CarterConfigurator carterConfigurator)
   at Carter.CarterExtensions.AddCarter(IServiceCollection services, DependencyContextAssemblyCatalog assemblyCatalog, Action`1 configurator)
   at Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.AddMintWebApp(WebApplicationBuilder builder)
   at Program.<Main>$(String[] args) in Program.cs:line 12

Current workaround

Simply remove the 'single file' option.

Additional information

Basically it works OK as long as you don't try to publish with the 'single file' option. Tested all other combinations and it works OK. Reason for using 'single file' is more for simplicity, massive reduction in files (rather than overall size - although that is a consideration). So work around is personally acceptable but def. be nice to have.

@datnguyen293
Copy link

I'm facing the same problem. Currently, uncheck the single file works but it makes the deployment process complicated.

@ritasker
Copy link
Member

As of .Net 6, getting the DependencyContext of an application deployed as a single-file is not supported. Carter is using the DependencyContext in the DependencyContextAssemblyCatalog.

The issue can be tracked here dotnet/runtime#70438

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

No branches or pull requests

3 participants