NickCraver / StackExchange.Exceptional

Error handler used for the Stack Exchange network
https://nickcraver.com/StackExchange.Exceptional/
Apache License 2.0
859 stars 170 forks source link

.NET Core 2.1 support #140

Closed radenkozec closed 5 years ago

radenkozec commented 5 years ago

I am trying this to make work in .NET Core 2.1 project without success. My appsettings.json looks like this: "Exceptional": { "ApplicationName": "LanacoIntSrv", "ErrorStore": { "Type": "PostgreSql", "ConnectionString": "Server=localhost;Port=5432;Database=lanacointsrv;User Id=admin;Password=admin;" } I added exceptional like this

  services.AddExceptional(Configuration.GetSection("Exceptional"),
            settings =>
            {
               settings.UseExceptionalPageOnThrow = HostingEnvironment.IsDevelopment();

            });

When I throw the error it is stated that memory store is used. I installed both packages with version 2.0.0-rc2.28 Any tips?

radenkozec commented 5 years ago

I figured out that my config is wrong. Documentation for .NET Core is not updated: https://nickcraver.com/StackExchange.Exceptional/AspDotNetCore

Config is now like this:

 "Exceptional": {
    "Store": {
      "ApplicationName": "LanacoIntSrv",
      "Type": "PostgreSql",
      "ConnectionString": "Server=localhost;Port=5432;Database=lanacointsrv;User Id=admin;Password=admin;"

    }
  }

but still does not working.

radenkozec commented 5 years ago

In Output windows I am getting this error: Could not find error store type: PostgreSql

radenkozec commented 5 years ago

I founded that error is here:

  private static List<Type> GetErrorStores()
        {
            var result = new List<Type>();
            try
            {
                // Ensure all assemblies we expect are loaded before looking at types
                var assemblyUri = new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase);
                var path = Path.GetDirectoryName(assemblyUri.LocalPath);

.Net Core 2.1 does not copy to output folder NuGet packages so this code does not work. When I copy dll-s manually still does not work. It seams that this library does not work on .NET Core 2.1?

NickCraver commented 5 years ago

Can you share how you're referencing the nuget in your .csproj? I can't repro here, perhaps it's a reference gotcha.

Also, thanks for the docs heads up - they're updated now.

radenkozec commented 5 years ago

@NickCraver I am not have access to that project right now until Monday but I have referenced Nuget package as usual using Visual Studio search box. I have noticed that NuGet packages are not automatically copied to output folder in .NET Core 2.1 so your code will not work in 2.1. Have you tested it with .NET Core 2.1? I am sure that it works in .NET Core 2.0 but 2.1 seams to have breaking changes...

NickCraver commented 5 years ago

@radenkozec yep, at least a few weeks ago upgrading the sample project to 2.1 works fine (it's out of pre-release so I could do this for everyone now...will do so tonight).

radenkozec commented 5 years ago

@NickCraver I will try it again on Monday I am on vacation. I am using VS 2017 Preview. https://developercommunity.visualstudio.com/content/problem/47828/nuget-content-packages-not-copied-in-vs-2017-new-c.html Maybe that is the problem that is causing NuGet packages to not output?

NickCraver commented 5 years ago

Any update? We're using this without issue on netcoreapp2.1 apps at Stack Overflow now - no content packages involved so no on that issue :)

radenkozec commented 5 years ago

@NickCraver Not sure how do you are using it without Visual Studio 2017 Preview. Working on .NET Core 2.1 project on old VS 2017 is not recommended by Microsoft. I use VS 2017 Preview which seams to work differently with NuGet packages. I did not test is later. Just give up using Exceptional because it takes to much time for me to figure out what is not working...

NickCraver commented 5 years ago

@radenkozec sorry to hear you had issues, this is the first report I've had, and without a repro I won't be able to help much :( It sounds like you're hitting general netstandard issues with libraries (of which there are many) rather than Exceptional specifically, though. If you ever give it another try I'm happy to help.

Going to close this our for now - happy to reopen if anyone hits similar.