[CSHARP-4201] MongoDB.Driver not supporting AOT native build Created: 08/Jun/22  Updated: 16/Jun/22  Resolved: 16/Jun/22

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Unknown
Reporter: Jaafar N/A Assignee: Boris Dogadov
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Generic exception not supported by AOT native build, is there anyway to change generic exception from your side?

Please check this for more details

 

https://github.com/dotnet/runtime/issues/70400



 Comments   
Comment by Boris Dogadov [ 16/Jun/22 ]

We are glad that you found a workaround for this issue. Given that this issue might to be fixed .NET 7 final release, we are closing this driver issue as Won't Fix. If it is present in the final release of .NET 7, please re-open this issue so that we can re-triage the problem.

Comment by Jaafar N/A [ 14/Jun/22 ]

Thank you for looking into it,

The problem with catching generic exception, you need c# application and add Microsoft.ILComplier for AOT native build.

I mange to solve it by downloading MangoDB.Driver project code, and I have updated the generic exception

catch (MongoBulkWriteException<TDocument> ex) 

to 

catch (Exception ex) when (ex is MongoBulkWriteException<TDocument>)

{{}}

In the following file

https://github.com/mongodb/mongo-csharp-driver/blob/master/src/MongoDB.Driver/MongoCollectionBase.cs#L245

{{}}

Then it worked with native build

Comment by Boris Dogadov [ 13/Jun/22 ]

Hi jaafar.abusair@gmail.com,
Hopefully this issue is going to be resolved in the final .Net 7 release.
If not, we will reconsider addressing this issue.

We could not easily reproduce this issue.
It would be great to have a full self-contained sample demonstrating the failure, so we could better track the resolution if this issue.

Thanks

Comment by Boris Dogadov [ 08/Jun/22 ]

Hi jaafar.abusair@gmail.com, thank you for your question, we will be looking into it.
Please follow this ticket for further updates.

Generated at Wed Feb 07 21:47:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.