This article is a mirror article of machine translation, please click here to jump to the original article.

View: 23580|Reply: 1

[Source] Generic context-bound objects: ContextBoundObject and generic classes are not supported

[Copy link]
Posted on 4/6/2017 2:16:25 PM | | | |
I just planned to add such a class to handle the generic return of the query in CYQ.Data's OrmBase:



OrmBase class:



Everything is very good, the compilation time is normal, but there is an exception at runtime: generic context binding objects are not supported



After some understanding, it is the reason why "ContextBoundObject" does not support generic classes, and there is such a passage on Microsoft MSDN:

Instructions for implementers
The current version of the public language runtime does not support generic ContextBoundObject types or non-generic types in ContextBoundObject, generic methods. Trying to create an instance of such a type will result in a TypeLoadException.


Now that you know, you have to think about how to deal with it in a roundabout way...






Previous:.net/c# Singles' Day Programmer Level 9 Decryption [Source Code]
Next:.ctor and .cctor of .net
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com