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

Exception: Could not find error store type: MySQL #160

Open
johnboker opened this issue Jan 23, 2019 · 2 comments
Open

Exception: Could not find error store type: MySQL #160

johnboker opened this issue Jan 23, 2019 · 2 comments

Comments

@johnboker
Copy link
Contributor

johnboker commented Jan 23, 2019

When trying to use the MySQL error store on a dotnet core 2.2 application I get the following error:

Exception: Could not find error store type: MySQL
StackExchange.Exceptional.ErrorStore.Get(ErrorStoreSettings settings)
StackExchange.Exceptional.Internal.ExceptionalSettingsBase.get_DefaultStore()
StackExchange.Exceptional.ExceptionalMiddleware.HandleRequestAsync(HttpContext context)
ProjectName.AdminController.Exceptions() in AdminController.cs
+
public async Task Exceptions() => await ExceptionalMiddleware.HandleRequestAsync(HttpContext);

After a bit of investigation it looks like it might be having trouble finding the StackExchange.Exceptional.MySQL.dll

var path = Path.GetDirectoryName(assemblyUri.LocalPath);

On my machine the dll is in the .nuget folder /Users/johnboker/.nuget/packages/stackexchange.exceptional.mysql/2.0.0/lib/netstandard2.0

The bin folder in the project only contains my dlls and a ProjectName.deps.json that references dependencies. I'm guessing since it's not in the same folder as the loading assembly it wont find it correctly.

A bit below the above referenced line there is a call to AppDomain.CurrentDomain.GetAssemblies()

I thought that might get what was needed but when I put that in Main the following is output:

List of assemblies loaded in current AppDomain:

System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
ProjectName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Runtime.Extensions, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Console, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.AspNetCore.Hosting.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
Microsoft.AspNetCore.Hosting, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 

Here's my config:

"Exceptional": {
    "Store": {
      "ApplicationName": "ProjectName",
      "Type": "MySQL",
      "ConnectionString": "server=myserver;port=3306;database=exceptional;uid=xxxx;password=xxxx;"
    }

In the csproj I have:

  <ItemGroup>
    ...
    <PackageReference Include="MySql.Data" Version="8.0.13" /> 
    <PackageReference Include="StackExchange.Exceptional.MySQL" Version="2.0.0" />
    <PackageReference Include="StackExchange.Exceptional.AspNetCore" Version="2.0.0" />
  </ItemGroup>

So, what am I doing wrong?

@johnboker
Copy link
Contributor Author

Just found that adding the following to the Main function before running the CreateWebHostBuilder causes it to work as expected, not sure if this would break things for other people.

var exceptionalDependencies = DependencyContext.Default.RuntimeLibraries
                                            .Where(a => a.Name.StartsWith("StackExchange.Exceptional.", StringComparison.InvariantCultureIgnoreCase));
foreach (var l in exceptionalDependencies)
{ 
     Assembly.Load(l.Name);
}

@NickCraver
Copy link
Owner

@johnboker Sorry I'm slow here - I'm going to talk to the .NET team in person in a few weeks and see how they want this to work...since the method keeps breaking between versions, I need to find out what is, or establish, a supported way for module loading.

It's a bit counter to their efforts of fastest startup possible, so trusting library authors to only load what's needed (which is the case here) isn't awesome. I get what they're doing...but it keeps breaking reality on startup and I need to have some chats.

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

2 participants