Hello,
I am re-developing a custom module with its own data provider in a DNN 9.13 dev instance. In the DataContext class, I have to create the provider by using Reflection.CreateObject. I have a message telling me that this is obsolete and that I should use an overload with IServiceProvider. I could not find samples or documentation for this. Can someone help me to identify a documentation or example that I could learn from?
Thanks a lot.
Dear Daniel,
Thanks a lot for your reply. My custom module is used to retrieve lists of documents to populate different tabs. Those documents are stored in a document management system. I am usinig its API to retrieve the necessary data for my module, hence my need for an abstract DataContext Class to link with DataProvider Class that handles the API calls to the document management system. Here is my code:
public abstract class MfilesDataContext {
#region "Shared/Static Methods"
// singleton reference to the instantiated object private static MfilesDataContext objProvider;
// static constructor static MfilesDataContext() { CreateProvider(); }
// dynamically create provider private static void CreateProvider() { objProvider = (MfilesDataProvider)DotNetNuke.Framework.Reflection.CreateObject("mfiles", "Brs.Modules.MFiles.Data", ""); //I have a warning here: "reflection.CreateObject(string, string, string) is obsolete. deprecated in DotNetNuke 9.11.3. Please use overload with IServiceProvider. Scheduled for removal in v11.0.0" }
// return the provider public static MfilesDataContext Instance() { return objProvider; }
#endregion
#region "Abstract methods"
public abstract IQueryable GetViews(string VaultName);
etc.
} }
Dear Daniel and Mitchel,
Thank you very much! An eye opener!
Indeed, this module was originally developed for DNN 4 and went trough all updates since. This time, I used Chris templates to make it as a SPA module and did not realize that I simply need to call my DataProvider instance from the Repositary class that inherits ServiceLocator. All is in order now.
All the best.
These Forums are for the discussion of the open source CMS DNN platform and ecosystem.
For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:
Awesome! Simply post in the forums using the link below and we'll get you started.