Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesError using dataproviderError using dataprovider
Previous
 
Next
New Post
2/22/2012 4:32 PM
 

Hi, i'm Emiliano from Rome Italy and i'm trying to build a module to manage video on my website but when i try to use the dataprovider.cs to connect with the data i get the error below:

System.ArgumentNullException: Value cannot be null.
Parameter name: type at System.Activator.CreateInstance(Type type, Boolean nonPublic) at DotNetNuke.Framework.Reflection.CreateObject(String ObjectProviderType, String ObjectProviderName, String ObjectNamespace, String ObjectAssemblyName, Boolean UseCache) at DotNetNuke.Framework.Reflection.CreateObject(String ObjectProviderType, String ObjectNamespace, String ObjectAssemblyName) at Blekke.PlayVideo.DataProvider.CreateProvider() in C:\inetpub\wwwroot\playvideo\DesktopModules\Blekke.PlayVideo\App_Code\DataProvider.cs:line 55 at Blekke.PlayVideo.DataProvider..cctor() in C:\inetpub\wwwroot\playvideo\DesktopModules\Blekke.PlayVideo\App_Code\DataProvider.cs:line 49 - The type initializer for 'Blekke.PlayVideo.DataProvider' threw an exception. 

the error is throw on the instruction :
objProvider = (DataProvider)Reflection.CreateObject("data", "Blekke.PlayVideo", "Blekke.PlayVideo.SqlDataProvider,Blekke.PlayVideo");
where the parameter means (or i would they means):
"data": ObjectProviderType
"Blekke.PlayVideo": ObjectNameSpaces
"Blekke.PlayVideo.SqlDataProvider,Blekke.PlayVideo": ObjectAssemblyName

Now, i've understand that the problem is a null value passed to the System.Activator.CreateInstance() but i can't understand what is the parameter.

Below the complete code of my dataprovider.cs
using System;
using System.Data;


using DotNetNuke;
using DotNetNuke.Framework;


namespace Blekke.PlayVideo
{
    public abstract class DataProvider
    {

        private static DataProvider  objProvider = null;

        static DataProvider()
        {
            CreateProvider();
        }

        private static void CreateProvider()
        {
            objProvider = (DataProvider)Reflection.CreateObject("data", "Blekke.PlayVideo", "Blekke.PlayVideo.SqlDataProvider,Blekke.PlayVideo");
        }

        public static  DataProvider Instance() 
        {
            return objProvider;
        }

            public abstract void AddPlayVideo(int ModuleId, string Content, int UserId);
            public abstract IDataReader GetPlayVideo(int ModuleId, int ItemId);
            public abstract IDataReader GetPlayVideos(int ModuleId);
            public abstract void UpdatePlayVideo(int ModuleId, int ItemId, string Content, int UserId);
            public abstract void DeletePlayVideo(int ModuleId, int ItemId);

        public abstract void PlayVideo_Serie_Insert(String Serie, String Icona);
        public abstract void PlayVideo_Categorie_Insert(String Descrizione, String Icona);
        public abstract void PlayVideo_SottoCategorie_Insert(String Descrizione, int IdCategoria, String Icona);
        public abstract void PlayVideo_Video_Insert(Int32 sc, Int32 s, String nv, String tv, String dv, Int32 c, String vp, String t, String a, String d);

        public abstract IDataReader PlayVideo_Serie_Select(String Serie);
        public abstract IDataReader PlayVideo_Categorie_Select(String Descrizione);
        public abstract IDataReader PlayVideo_SottoCategorie_Select(Int32 IdCategoria, String Descrizione);
        public abstract IDataReader PlayVideo_Video_Select(Int32 v, String t, Int32 c, Int32 sc, Int32 s, String a, Int32 u);

    }
}

I hope you can help me.
Thanks Emiliano

 
New Post
2/22/2012 9:58 PM
 

It would appear that the problem lies in your providing an assembly qualified type name as the third parameter to CreateObject:

objProvider = (DataProvider)Reflection.CreateObject("data", "Blekke.PlayVideo", "Blekke.PlayVideo.SqlDataProvider,Blekke.PlayVideo");

For the CreateObject method taking three string parameters when both the second parameter (objectNamespace) and third parameter (objectAssembly) are non-null or empty, the code will build the object type name as follows:

TypeName = ObjectNamespace + "." + objProviderConfiguration.DefaultProvider + ", " + ObjectAssemblyName + "." + objProviderConfiguration.DefaultProvider;
In your case this will result in "Blekke.PlayVideo.SqlDataProvider, Blekke.PlayVideo.SqlDataProvider, Blekke.PlayVideo.SqlDataProvider" which would not appear to be correct - note the second comma.
Try either of the following depending on whether or not you have a separate assembly for the SqlDataProvider:
objProvider = (DataProvider)Reflection.CreateObject("data", "Blekke.PlayVideo", "Blekke.PlayVideo.SqlDataProvider"); 
objProvider = (DataProvider)Reflection.CreateObject("data", "Blekke.PlayVideo", "");
Also, as I recall both the abstract DataProvider and the concrete SqlDataProvider classes must have the same namespace for CreateObject to be able to instantiate the SqlDataProvider.

Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesError using dataproviderError using dataprovider


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out