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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Cannot Create Custom SQLDataProviderCannot Create Custom SQLDataProvider
Previous
 
Next
New Post
6/22/2007 5:10 PM
 

I have a need to create a custom SqlDataProvider for DNN (v4.05.03).  However, once I created it and made my optimizations and changes, I began receiving the following error:

System.ArgumentNullException: Value cannot be null.  Parameter name: type

Having created alternate providers before, I know that this error normally points to the "type" value of the provider node being incorrect (missing, typo, etc.).  However, this is not the case.  I copied and pasted to ensure this (and over and over again during troubleshooting).

So, in order to remove the variables of my changes, I recreated the error and this problem by creating a new project pointing at the DNN dll and then copied and pasted the default data provider code from DNN.  I had to make 5 changes in order for this work.  These were to move the type into my namespaces, and to avoid namespace/type ambiguity.  Here are the changes:

Line 35:  (FROM) Namespace DotNetNuke.Data  
(TO) Namespace MyCompany.Provider
Line 37: (FROM) Public Class SqlDataProvider
(TO) Public Class PortalSqlDataProvider
Line 38: (FROM) Inherits DataProvider
(TO) Inherits DotNetNuke.Data.DataProvider
Line 56: (FROM) Dim objProvider As Provider = CType(_providerConfiguration.Providers(_providerConfiguration.DefaultProvider), Provider)
(TO) Dim objProvider As DotNetNuke.Framework.Providers.Provider = CType(_providerConfiguration.Providers(_providerConfiguration.DefaultProvider), DotNetNuke.Framework.Providers.Provider)
Line 150: (FROM) If RoleID.ToString = Common.Globals.glbRoleNothing Then
(TO) If RoleID.ToString = DotNetNuke.Common.Globals.glbRoleNothing Then

I KNOW that this is all I have changed because I am using software to compare the two files.  When I compile the new provider and deploy it to the bin of the DNN site, I also add the following line to the Web.Config:

<add name="MyCompanySqlDataProvider" type="MyCompany.Provider.PortalSqlDataProvider, MyCompany.SqlDataProvider" connectionStringName="SiteSqlServer" upgradeConnectionString="" providerPath="~\Providers\DataProviders\SqlDataProvider\" objectQualifier="" databaseOwner="dbo" />

As you can see, this is identical to the line used for the DNN provider except that there are the necessary changes for "type" and "name".  I also changed the "defaultProvider" value to match the new provider "name" (copied and pasted).  Here is the finished product:

<data defaultProvider="MyCompanySqlDataProvider">
  <providers>
    <clear />
    <add name="MyCompanySqlDataProvider" type="MyCompany.Provider.PortalSqlDataProvider, MyCompany.SqlDataProvider" connectionStringName="SiteSqlServer" upgradeConnectionString="" providerPath="~\Providers\DataProviders\SqlDataProvider\" objectQualifier="" databaseOwner="dbo" />
    <add name="SqlDataProvider" type="DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider" connectionStringName="SiteSqlServer" upgradeConnectionString="" providerPath="~\Providers\DataProviders\SqlDataProvider\" objectQualifier="" databaseOwner="dbo" />
  </providers>
</data>

 I have verified in the bin directory that the DLL is present and accounted for.  Also, the name matches the defined name in the provider configuration above.  Just to be sure that the DLL is indeed found, I tried changing the value of "type" and the error changed.  In addition, I have also deleted the temporary files for the DNN sites (several times). 

As a final troubleshooting step, I built and ran the source version of DNN v4.05.03 and set breakpoints to the line in Reflection.vb (line: 227) that this error occurs at, and all of the arguments are valid and NOT null.  The CreateInstance method of the mscorlib.Activator class is throwing this error.

Line 227: Return Activator.CreateInstance(CreateType(TypeName, CacheKey, UseCache))

Each time I try to use this new (almost unchanged) provider, I get the same error:

System.ArgumentNullException: Value cannot be null.  Parameter name: type

Does anyone know what the problem is?  I am killing myself trying to get this to work.  Most importantly, can you recreate this problem using the same steps I described?


Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
New Post
6/22/2007 5:16 PM
 

Does the project for your new SqlDataProvider have a root namespace defined?  That will make your namespace (inexplicably) be incorrect.


Brian Dukes
Engage Software
St. Louis, MO
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
New Post
6/22/2007 5:23 PM
 

I missed something in the debugger.  When I step through it, the CreateType method that ends up getting called from Line 227 om Reflection.vb.  This turns over the request to an overload of CreateType where the UseCache argument is True.  This of course attempts to grab the object from cache.  When I stepped through just now, there must have indeed been a copy of the object in cache, because it returned the object.  Here is a copy of the code I am referring to in Reflection.vb:

        Public Shared Function CreateType(ByVal TypeName As String, ByVal CacheKey As String, ByVal UseCache As Boolean, ByVal IgnoreErrors As Boolean) As Type
            If CacheKey = "" Then
                CacheKey = TypeName
            End If
            Dim objType As Type = Nothing
            ' use the cache for performance
            If UseCache Then
                objType = CType(DataCache.GetCache(CacheKey), Type) ' THIS IS LINE 271 WHERE THE CACHED VERSION IS RETURNED :(
            End If
            ' is the type in the cache?
            If objType Is Nothing Then
                Try
                    ' use reflection to get the type of the class
                    objType = BuildManager.GetType(TypeName, True, True)
                    If UseCache Then
                        ' insert the type into the cache
                        DataCache.SetCache(CacheKey, objType)
                    End If
                Catch exc As Exception
                    ' could not load the type
                    If Not IgnoreErrors Then
                        LogException(exc)
                    End If
                End Try
            End If
            Return objType
        End Function

Although, I did mention that I got rid of the Temporary ASPNet files, I have also restarted IIS using the method below (I have a shortcut to a batch file on my taskbar).

iisreset /RESTART /TIMEOUT:20s

I guess that the final step is to try rebooting or something...  :(


Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
New Post
6/22/2007 5:25 PM
 

dukesb11 wrote

Does the project for your new SqlDataProvider have a default namespace defined?  That will make your namespace (inexplicably) be incorrect.

Great question.  I thought that I should've mentioned that.  I did indeed remove the default namespace.  It is now blank.  That is necessary for the project to build properly.


Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
New Post
6/22/2007 5:54 PM
 

Have you tried removing the assembly name from your type declaration in the web.config?  I get that error when I have the wrong assembly name, but it clears up when I remove the assembly name altogether.

Just to note, I was getting the error that you were talking about,  but I just had to change the project to compile into the Website/bin folder, and make sure that I had the right type/assembly in the web.config, and then it cleared.

Hope it helps,


Brian Dukes
Engage Software
St. Louis, MO
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Cannot Create Custom SQLDataProviderCannot Create Custom SQLDataProvider


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