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

[dotnet-sdk-9.0.100-preview.3.24160.1] Freesql error: Ambiguous match found for 'System.TimeSpan System.TimeSpan FromSeconds(Int64)'. #99588

Closed
Junjun-zhao opened this issue Mar 12, 2024 · 3 comments
Labels
area-Meta question Answer questions and provide assistance, not an issue with source code or documentation.

Comments

@Junjun-zhao
Copy link
Member

Junjun-zhao commented Mar 12, 2024

Description

When running 3rd party application with the latest .NET 9 build, it stops working after launching. After investigation, we found it is caused by FreeSql. The exception from Visual Studio output window is: Ambiguous match found for 'System.TimeSpan System.TimeSpan FromSeconds(Int64)'.

Reproduction Steps

Minimal Repro steps (Demo attached:ConsoleDemo.zip):
The machine has dotnet-sdk-9.0.100-preview.3.24160.1 installed.
1.Create a new net8.0 Console project.
2.Copy the following code to Program.cs.

using FreeSql;
string ConnetionString = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=Demo;";
var freeBuilder = new FreeSqlBuilder().UseConnectionString(DataType.SqlServer, ConnetionString).Build();
Console.WriteLine(freeBuilder);

3.Install FreeSql.Provider.SqlServer nuget package.
4.Build the app.
5.Change the runtime.config file to let the app run against with dotnet-sdk-9.0.100-preview.3.24160.1.

    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "9.0.0-preview.3.24157.12"
    }
  1. Launch the app.

Expected behavior

Launch successfully.

Actual behavior

System.TypeInitializationException: 'The type initializer for 'FreeSql.Internal.Utils' threw an exception.'
AmbiguousMatchException: Ambiguous match found for 'System.TimeSpan System.TimeSpan FromSeconds(Int64)'.

Regression?

Yes
Verify Scenarios:
1). Windows 10 21H2 AMD64 + dotnet-sdk-8.0.101: Pass
2). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-preview.2.24129.7: Pass
3). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-preview.3.24160.1: Fail

Known Workarounds

No response

Configuration

Application Name: EasyCMS,CastIt,HyggeImaotai
OS: Windows 10 21H2
CPU: X64
.NET Build Number: dotnet-sdk-9.0.100-preview.3.24160.1
App & Source Location checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1992393
Github Link:
https://github.com/yushuo1990/EasyCMS
https://github.com/Wolfteam/CastIt
https://github.com/lisongkun/HyggeImaotai

Other information

Dotnet Info:

.NET SDK:
Version:           9.0.100-preview.3.24160.1
Commit:            232d2df252
Workload version:  9.0.100-manifests.9f73df61
MSBuild version:   17.10.0-preview-24127-03+6f44380e4

Runtime Environment:
OS Name:     Windows
OS Version:  10.0.19045
OS Platform: Windows
RID:         win-x64
Base Path:   C:\Program Files\dotnet\sdk\9.0.100-preview.3.24160.1\

 .NET workloads installed:

There are no installed workloads to display.

 Host:

  Version:      9.0.0-preview.3.24157.12
  Architecture: x64
  Commit:       da781b3aab

 .NET SDKs installed:

  9.0.100-preview.3.24160.1 [C:\Program Files\dotnet\sdk]

 .NET runtimes installed:

  Microsoft.AspNetCore.App 9.0.0-preview.3.24157.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.0-preview.3.24157.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 9.0.0-preview.3.24158.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

@dotnet-actwx-bot @dotnet/compat

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Mar 12, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Mar 12, 2024
@stephentoub
Copy link
Member

stephentoub commented Mar 12, 2024

This is a bug in the FreeSql library. This line is expecting there to only be one overload of TimeSpan.FromSeconds, but there are now multiple overloads, which leads to GetMethod throwing an ambiguity exception because it doesn't know which method to bind to:
https://github.com/dotnetcore/FreeSql/blob/e1f91ef361ca4a6eac7f217bd4a474047597e4e3/FreeSql/Internal/UtilsExpressionTree.cs#L2172

@jeffschwMSFT jeffschwMSFT added question Answer questions and provide assistance, not an issue with source code or documentation. area-Meta labels Mar 12, 2024
@vcsjones vcsjones removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Mar 12, 2024
@Junjun-zhao
Copy link
Member Author

This is a bug in the FreeSql library. This line is expecting there to only be one overload of TimeSpan.FromSeconds, but there are now multiple overloads, which leads to GetMethod throwing an ambiguity exception because it doesn't know which method to bind to: https://github.com/dotnetcore/FreeSql/blob/e1f91ef361ca4a6eac7f217bd4a474047597e4e3/FreeSql/Internal/UtilsExpressionTree.cs#L2172

Thank you @stephentoub for looking into this issue so quickly. We've filed an Freesql issue to notify the owner about this issue. Closing this issue.

@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Mar 13, 2024
@2881099
Copy link

2881099 commented Mar 14, 2024

FreeSql.3.2.816-preview20240314

@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Meta question Answer questions and provide assistance, not an issue with source code or documentation.
Projects
None yet
Development

No branches or pull requests

5 participants