You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MongoDb GetCollection error: get MakeGenericMethod may only be called on a method for which MethodBase.IsGenericMethodDefinition is true. #816
System.InvalidOperationException: MongoDB.Driver.IMongoCollection`1[TDocument] GetCollection[TDocument](System.String, MongoDB.Driver.MongoCollectionSettings) is not a GenericMethodDefinition. MakeGenericMethod may only be called on a method for which MethodBase.IsGenericMethodDefinition is true.
publicabstractclassMyBaseClass{publicabstractTGetCollection<T>();// this is just a helper to get an instance of the internal classpublicstaticMyBaseClasstest(){returnnewMyInternalClass();}}internalsealedclassMyInternalClass:MyBaseClass{publicoverrideTGetCollection<T>(){thrownewNotImplementedException();}}
MyBaseClass.test().GetCollection[object]
which results in:
SystemError: T GetCollection[T]() is not a GenericMethodDefinition. MakeGenericMethod may only be called on a method for which MethodBase.IsGenericMethodDefinition is true.
A possible workaround is to enable private bindings with the PrivateBinding option.
Activity
slozier commentedon May 24, 2022
The issue appears to be something like this:
which results in:
A possible workaround is to enable private bindings with the
PrivateBindingoption.bnuzhouwei commentedon May 25, 2022
Thanks, you are right, the code in mongodb driver is:
Internal without public....,
But how to to enable private bindings with the PrivateBinding option? Can add any paramters to the CreateEngine method?
bnuzhouwei commentedon May 25, 2022
I modified the source code, changed the class MongoDatabaseImpl from internal to public, and recompile it.
The GetCollection in above code run correctly, but in mongodb, there are many methods with default value as default(CancellationToken), i.e.
but in IronPython, when we call the method:
got
I seems that IronPython does't support default value for structs, such as default(CancellationToken)
slozier commentedon May 25, 2022
You can enable private binding like this: