[CSHARP-4843] Suppress any exceptions in the code checking for legacy driver loaded Created: 13/Nov/23 Updated: 23/Nov/23 Resolved: 23/Nov/23 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 2.22.0 |
| Fix Version/s: | 2.23.0 |
| Type: | Bug | Priority: | Blocker - P1 |
| Reporter: | Wesam Abdallah | Assignee: | Oleksandr Poliakov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | MongoDB.Driver.Core.Connections.ClientDocumentHelper, NRE | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Backwards Compatibility: | Fully Compatible |
| Documentation Changes: | Not Needed |
| Documentation Changes Summary: | 1. What would you like to communicate to the user about this feature? |
| Description |
| Comments |
| Comment by Githook User [ 23/Nov/23 ] | ||||||||
|
Author: {'name': 'Oleksandr Poliakov', 'email': '31327136+sanych-sun@users.noreply.github.com', 'username': 'sanych-sun'}Message: | ||||||||
| Comment by Oleksandr Poliakov [ 15/Nov/23 ] | ||||||||
|
Sure, that's definitely makes sense to suppress any exception in that code block. I'm just trying to reproduce the issue, so I can ensure it's gone after the changes. | ||||||||
| Comment by Wesam Abdallah [ 15/Nov/23 ] | ||||||||
|
One aspect worth noting is that the calling function code is running contextually inside of Windows service. If you are trying to reproduce this issue, create a Windows service with the new driver
What would be the harm in wrapping up those checks in try/catch?
| ||||||||
| Comment by Wesam Abdallah [ 15/Nov/23 ] | ||||||||
|
The exception happens because "I think" this function is called from a cpp handler
Others are also dealing with this, they have to add the `mongocsharpdriver` in addition to the new MongoDB.Driver https://stackoverflow.com/questions/29441456/mongodb-drivers-query-builder-missing-from-drivers
| ||||||||
| Comment by Oleksandr Poliakov [ 14/Nov/23 ] | ||||||||
|
Hi wamra2004-developer@yahoo.com ! Thank you for reporting the problem. We do not have hard dependency onto the legacy driver, we rather checking if the legacy driver is present in the app domain and update MongoClient properties accordingly (you can see this as a User-Agent string). Talking about the exception itself: it looks a little weird, because the Type.GetType method should not throw if type is not available accordingly to the documentation And as a result I cannot reproduce the issue. Could you please try to create a minimal application to reproduce the issue? Also some additional information could help: like a is there any frameworks being used that might affect type/assembly loading, some hosting details (net framework version? is it mono?)
Thanks, Oleksandr Poliakov | ||||||||
| Comment by Wesam Abdallah [ 13/Nov/23 ] | ||||||||
|
This a very bad mistake.. I looked further into it, we are not using MongoServer, we are only using the new MongoClient... Why is the driver throwing an exception while checking if the legacy type/lib is available? You introduced a dependency from the new API to the older legacy `MongoDB.Driver.MongoServer, MongoDB.Driver.Legacy` The issues in this section ... ``` ``` This type was removed from the latest MongoDB.Driver.Legacy 2.22.0 Please remove this dependency and release an update
| ||||||||
| Comment by PM Bot [ 13/Nov/23 ] | ||||||||
|
Hi wamra2004-developer@yahoo.com, thank you for reporting this issue! The team will look into it and get back to you soon. |