-
Notifications
You must be signed in to change notification settings - Fork 148
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
Version 5.4 causes an exception trying to load Microsoft.Azure.Services.AppAuthentication #283
Comments
Hi @arex388, Would you be able to provide a working (or not as the case may be) sample application which reliably reproduces the problem in AWS, I'd then be more than happy to take a look and try to resolve for you. No Charge! :) |
Hi @arex388! Thank you for informing us about the issue. Can you please give us the list of files in the output folder after you called |
Looks like the dependency on IMO |
These conditions do specify minimum versions. The Azure Manages Identities features also works when using the sink in a program targeting .NET Core 3.1. I tested this and documented the result in PR 222: The conditional dependency is necessary because the referenced assembly is not supported on all frameworks the sink targets. On the frameworks where it is not supported, the dependency is not used and the implementation is swapped with a stub that does nothing except throwing an exception when enabling the feature by configuration. |
But probably we can change the code to call the ctor of I will take a look into it. |
Hi @ckadluba could we have a catch up?Can provide the temp email again if needed. |
I sent you my contact now. :) |
I thought about this. I think Microsoft.Azure.Services.AppAuthentication is a dependency like any other and should not require any special treatment in the sink. The assembly should be deployed with the consumer app along with all other nuget packages. @arex388 have you had yet an opportunity to check the publish artifacts and the deployment of your app? Is the assembly missing there? |
@ckadluba I haven’t had a chance to yet. I’ve been stuck doing post-release bug fixes on the project where I discovered the issue. Once things begin to settle down with it I’ll take a look, but it most likely will be at least a week or two before that happens. Hopefully... |
Hi folks - I have this same problem. What I have found: I add the MSQL Sink back to my application (which adds the 1.4 version of the Azure library) via NuGet. Rebuild the solution. Then I reenable the commented out code that builds the Sink. When I run, I get an exception. It appears that there is an accidental reference to both the 1.5 and 1.4 version of the Azure library. Why would the Sink install the 1.4 version of the Azure library when it needs the 1.5? I still get errors if I install the 1.5 version of the Azure library. Here is the exception (note the 1.5 reference): And here is the Inner Exception (note the 1.4 reference): If I try to install the 1.5 version of the Azure library via NuGet, I get the following error:TF400024: The change on xxx\packages\Microsoft.Azure.Services.AppAuthentication.1.5.0\Microsoft.Azure.Services.AppAuthentication.1.5.0.nupkg cannot be undone because a file already exists at xxx\packages\Microsoft.Azure.Services.AppAuthentication.1.5.0\Microsoft.Azure.Services.AppAuthentication.1.5.0.nupkg. The file must be deleted from disk for the undo to succeed. I have tried everything. The only thing that seems to work is going with an older version of the MSQ sink that doesn't want the Azure library. |
One more thing. It appears to be related to the addition of SinkOptions in 5.4. If I go back to v. 5.3 I am able to run. |
@FletcherJohnsonZ thank you for the investigation and for sharing your findings. Do you have a sample project to reproduce the problem that you could provide me? Some points about your observations:
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.2' Or '$(TargetFramework)' == 'net472' ">
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.3" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.4.0" />
|
Be cautious! Message sent from external source.
Christian,
Unfortunately, I can’t share the project – this is for an internal project. But I can share the pertinent code.
The following works fine with MSSqlServer v 5.3. If I upgrade to 5.4 or 5.5, when this code tries to execute, it gets the errors I posted. I am not sure if it’s the instantiation of the sinkOptions or not. What I know is the Azure library that installs automatically with 5.5 (and 5.4, I believe) is where the issue appears to be. So it might be that your code uses one version, but the dependency install of the Azure library is installing the other.
All I know is that the exception references one version of the Azure library and the inner exception references the other.
To recreate – uninstall the SQL sink and azure library. Then just install the current sink, letting it install the azure library. Then run the code below, but changed to use the currently commented out sinkOptions and use that to set the table name. Then run. If you don’t get an error, I can try to get more details. But I already spent a lot of time trying to get things to work and I may have to wait until after the current release ships.
Note: Values in angle brackets were replaced (but then, you knew that….)
try
{
if (LogToSql && logcfg != null && !string.IsNullOrWhiteSpace(AppValues.DbLogConnection))
{
var logTable = "<tableName>";
// Create the sink and set values
// The following is used for V5.4+, but not 5.3
// var sinkOptions = new Serilog.Sinks.MSSqlServer.Sinks.MSSqlServer.Options.SinkOptions();
// set the sinkOptions table
// Create the column options
var columnOptionVals = new ColumnOptions
{
AdditionalColumns = new System.Collections.ObjectModel.Collection<SqlColumn>()
};
// Add columns we want to use
columnOptionVals.AdditionalColumns.Add(new SqlColumn("UserId", System.Data.SqlDbType.NVarChar, true, 50));
columnOptionVals.AdditionalColumns.Add(new SqlColumn("Version", System.Data.SqlDbType.NVarChar, true, 15));
// I don't think we need to save the template, since we can
// see the specific values in the Properties column
columnOptionVals.Store.Remove(StandardColumn.MessageTemplate);
columnOptionVals.LogEvent.DataLength = 2048;
columnOptionVals.PrimaryKey = columnOptionVals.TimeStamp;
columnOptionVals.TimeStamp.NonClusteredIndex = true;
// This was using sinkOptions, but that’s not available in 5.3
logcfg.MinimumLevel.Information()
.WriteTo.MSSqlServer(AppValues.DbLogConnection,
tableName: logTable,
restrictedToMinimumLevel: LogEventLevel.Information,
columnOptions: columnOptionVals);
}
}
catch (Exception ex)
{
<Handle error>
}
Fletcher Johnson
[cid:[email protected]]
510-474-9051 – Work
408-781-2345 – Cell
[email protected]
From: Christian Kadluba <[email protected]>
Sent: Saturday, June 20, 2020 1:22 PM
To: serilog/serilog-sinks-mssqlserver <[email protected]>
Cc: Johnson, Fletcher <[email protected]>; Mention <[email protected]>
Subject: [EXTERNAL] Re: [serilog/serilog-sinks-mssqlserver] Version 5.4 causes an exception trying to load Microsoft.Azure.Services.AppAuthentication (#283)
Be cautious! Message sent from external source.
@FletcherJohnsonZ<https://github.com/FletcherJohnsonZ> thank you for the investigation and for sharing your findings. Do you have a sample project to reproduce the problem that you could provide me?
Some points about your observations:
* The .NET Framework 4.7+ and .NET Core 2.2+ builds of Serilog.Sinks.MSSqlServer.dll reference Microsoft.Azure.Services.AppAuthentication 1.4.0. There should be no references to version 1.5.0 of that assembly. Here is the relevant snippet from the csproj file.
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.2' Or '$(TargetFramework)' == 'net472' ">
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.3" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.4.0" />
* In version 5.4.0 of the sink we added support for Azure manages identities and that was also the PR that introduced the nuget reference to Microsoft.Azure.Services.AppAuthentication 1.4.0. The problem has nothing to do with the introduction of the SinkOptions class (which was also added in 5.4.0).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#283 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ANEMI6K36E2AKXCJDCZKWALRXUK7VANCNFSM4M4S4ULQ>.
|
@FletcherJohnsonZ thanks for the sample. I'll try to reproduce the problem but I'm afk for the next two weeks, so I can probably do it only after the 7th of july. What target framework does your project use? |
Be cautious! Message sent from external source.
Christian,
We are currently targeting 4.7.2. It’s a WPF application.
Fletcher
Fletcher Johnson
[cid:[email protected]]
510-474-9051 – Work
408-781-2345 – Cell
[email protected]
From: Christian Kadluba <[email protected]>
Sent: Sunday, June 21, 2020 1:31 PM
To: serilog/serilog-sinks-mssqlserver <[email protected]>
Cc: Johnson, Fletcher <[email protected]>; Mention <[email protected]>
Subject: [EXTERNAL] Re: [serilog/serilog-sinks-mssqlserver] Version 5.4 causes an exception trying to load Microsoft.Azure.Services.AppAuthentication (#283)
Be cautious! Message sent from external source.
@FletcherJohnsonZ<https://github.com/FletcherJohnsonZ> thanks for the sample. I'll try to reproduce the problem but I'm afk for the next two weeks, so I can probably do it only after the 7th of july.
What target framework does your project use?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#283 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ANEMI6JYCKHJF2R44D7STEDRXZUXJANCNFSM4M4S4ULQ>.
|
I tried to reproduce and fix the problem you noticed but it seems to be more complicated than I expected. When I use a sample targeting .NET Framework (like
Same thing when I use the sample you provided. To me it is still unclear why that happens although there seemed to be an open issue in Microsoft.Data.SqlClient:: dotnet/SqlClient#361 Anyway, I had no success with adding a reference to Microsoft.Data.SqlClient.SNI v1.1.1 as suggested in their issue. I will continue investigating this but I cannot promise if or when I will be able to fix this. Therefore I will also mark this issue as "up for grabs" so hopefully someone will have a good idea how to solve it. |
I could fix the SNI problem. To summarize it again, since the migration from Like stated by the Microsoft.Data.SqlClient team in their issue 361 (linked above in my last comment), this can be fixed by adding a reference to Microsoft.Data.SqlClient in the consuming application. After I added such a reference to the AppConfigDemo project, the problem disappeared. I committed this change to the sink repo. So, if you use the sink from a .NET Framework (>= 4.6.1) project, you have to add a reference to Microsoft.Data.SqlClient to your project to avoid this exception. With AppConfigDemo the sink just works now, so I still could not reproduce the problem described by @FletcherJohnsonZ and others regarding a missing Microsoft.Azure.Services.AppAuthentication, Version=1.4.0.0. I'll keep this under investigation. |
Christian,
For now, if anyone is having this problem, they can back rev as I did since the earlier versions work fine.
In my environment, we can’t update libraries except as part of some other process anyway, so for now, we are locked into that version. I can check back when we are ready to start the next round of updates.
Thanks for the update,
Fletcher
Fletcher Johnson
[cid:[email protected]]
510-474-9051 – Work
408-781-2345 – Cell
[email protected]
From: Christian Kadluba <[email protected]>
Sent: Saturday, July 25, 2020 4:21 PM
To: serilog/serilog-sinks-mssqlserver <[email protected]>
Cc: Johnson, Fletcher <[email protected]>; Mention <[email protected]>
Subject: [EXTERNAL] Re: [serilog/serilog-sinks-mssqlserver] Version 5.4 causes an exception trying to load Microsoft.Azure.Services.AppAuthentication (#283)
Be cautious! Message sent from external source.
I tried to reproduce and fix the problem you noticed but it seems to be more complicated than I expected. When I use a sample targeting .NET Framework (like samples\AppConfigDemo), I get not quite the error you have but a different exception on application start:
System.TypeInitializationException: 'The type initializer for 'Microsoft.Data.SqlClient.SNINativeMethodWrapper' threw an exception.'
To me it is still unclear why that happens although there seemed to be an open issue in Microsoft.Data.SqlClient:: dotnet/SqlClient#361<dotnet/SqlClient#361>
Anyway, I had no success with adding a reference to Microsoft.Data.SqlClient.SNI v1.1.1 as suggested in their issue.
I will continue investigating this but i cannot promise when of if I will be able to fix this. Therefore I will also mark this issue as "up for grabs" so hopefully someone will have a good idea how to solve it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#283 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ANEMI6M64T4WXHVC36L7H53R5NSGHANCNFSM4M4S4ULQ>.
|
Hi, I encounter the The application is executed on Framework 4.6.1 and in my case the As I can see I am using the code on |
@ckadluba Sorry for the long delay in responding. Been busy with the project... Anyway, today I decided to give updating a try and I updated:
After publishing to the server the |
Hi @ckadluba, It is really great that this issue has been fixed but the same exception is thrown by the |
@arex388 that is good news. Thank you very much for taking the time and trying this out with the new versions and coming back with feedback. We appreciate this a lot. I'm closing this issue now. @ie-zero thanks for reporting the problem in |
As the title says, the latest version (5.4) causes an exception because its trying to load
Microsoft.Azure.Services.AppAuthentication
which doesn't exist. I don't use any Azure services and have never referenced any in my solution. Weirdly, it works fine when debugging locally, but as soon as its published to my server (IIS 10 on Windows Server 2019 on AWS EC2) the exception is thrown and I'm greeted with an ANCM 500.30 error. I've had to revert to 5.3 to avoid the exception on the server.Here's the exception trace for details:
Not throwing an exception for
Microsoft.Azure.Services.AppAuthentication
. It seems to be looking for regardless if its used or not.N/A
N/A
N/A
The text was updated successfully, but these errors were encountered: