jcook32
asked on
Dataprovider exception in dotnetnuke
I am creating a custom module for dotnetnuke and i cannot figure out why i am getting a dataprovider exception.
the error happens on this line: objProvider = CType(Framework.Reflection .CreateObj ect("data" , "PAAC.Modules.Stations.Dat a", "PAAC.Modules.Stations"), DataProvider)
this is the full error in the browser:
Error: StationPAAC is currently unavailable.
DotNetNuke.Services.Except ions.Modul eLoadExcep tion: The type initializer for 'PAAC.Modules.Stations.Dat a.DataProv ider' threw an exception. ---> System.TypeInitializationE xception: The type initializer for 'PAAC.Modules.Stations.Dat a.DataProv ider' threw an exception. ---> System.ArgumentNullExcepti on: Value cannot be null. Parameter name: type at PAAC.Modules.Stations.Data .DataProvi der.Create Provider() in C:\DNN560\Website\DesktopM odules\Sta tions\Comp onents\Dat aProvider. vb:line 73 at PAAC.Modules.Stations.Data .DataProvi der..cctor () in C:\DNN560\Website\DesktopM odules\Sta tions\Comp onents\Dat aProvider. vb:line 42 --- End of inner exception stack trace --- at PAAC.Modules.Stations.View Stations.B indGrid(St ring type) in C:\DNN560\Website\DesktopM odules\Sta tions\View Stations.a scx.vb:lin e 155 at PAAC.Modules.Stations.View Stations.P age_Load(O bject sender, EventArgs e) in C:\DNN560\Website\DesktopM odules\Sta tions\View Stations.a scx.vb:lin e 73 --- End of inner exception stack trace ---
i have tried everything.
Please help
jcook32
the error happens on this line: objProvider = CType(Framework.Reflection
this is the full error in the browser:
Error: StationPAAC is currently unavailable.
DotNetNuke.Services.Except
i have tried everything.
Please help
jcook32
ASKER
funny thing is there is not sqldataprovider dll in the bin directory.
when is that created?
when is that created?
It's ok if it doesn't have it's own DLL, it will only have that if the SQLDataProvider is located in its own project.
assuming that "PAAC.Modules.Stations.Dat a" is the namespace your SQLDataProvider class lives in, the provider instantiation should look like this:
objProvider = CType(Framework.Reflection .CreateObj ect("data" , "PAAC.Modules.Stations.Dat a", ""), DataProvider)
assuming that "PAAC.Modules.Stations.Dat
objProvider = CType(Framework.Reflection
ASKER
yes it is. i have a dataprovider.vb file with the same namesspace --"PAAC.Modules.Stations.D ata"
so both the sqldataprovider.vb and dataprovider have the same name space.
is this okay?
so both the sqldataprovider.vb and dataprovider have the same name space.
is this okay?
yes that is quite allright
did you try the modified instantiation code (by leaving the dll name empty)
did you try the modified instantiation code (by leaving the dll name empty)
ASKER
no. not sure what that is.
can you explain?
thanks
can you explain?
thanks
use this
objProvider = CType(Framework.Reflection .CreateObj ect("data" , "PAAC.Modules.Stations.Dat a", ""), DataProvider)
instead of
objProvider = CType(Framework.Reflection .CreateObj ect("data" , "PAAC.Modules.Stations.Dat a", "PAAC.Modules.Stations"), DataProvider)
to explain: this code instantiates the DataProvider that is set as default dataprovider in web.config (By default this is a SQLDataProvider in DNN)
objProvider = CType(Framework.Reflection
instead of
objProvider = CType(Framework.Reflection
to explain: this code instantiates the DataProvider that is set as default dataprovider in web.config (By default this is a SQLDataProvider in DNN)
ASKER
i get the same thing.
do i need to re-install the module definition within my local dnn install after each build? or is it enough to refresh the browser?
do i need to re-install the module definition within my local dnn install after each build? or is it enough to refresh the browser?
this is not a DNN error, the error means that your dataprovider is not where you say it is.
this can be caused by an incorrect namespace. This can happen if you added a default namespace to the project (in project properties), and also used the full namespace in your code file. A quick way to see what namespace your class is actually in is by using the visual studio object browser. Please verify that your dataprovider and sqldataprovider are actually in the namespace you think they are
Also, make sure that when you do a module build, the DLL is actually copied to the website bin folder
this can be caused by an incorrect namespace. This can happen if you added a default namespace to the project (in project properties), and also used the full namespace in your code file. A quick way to see what namespace your class is actually in is by using the visual studio object browser. Please verify that your dataprovider and sqldataprovider are actually in the namespace you think they are
Also, make sure that when you do a module build, the DLL is actually copied to the website bin folder
ASKER
is root namespace the same as default? if mine is blank
assembly name is PAAC.Modules.Stations
assembly name is PAAC.Modules.Stations
ASKER
Is there a way to make the call differently. rather than use the reflection method.
thanks
thanks
ASKER
a more detailed error
DotNetNuke.Services.Except ions.Modul eLoadExcep tion: Could not load type 'PAAC.Modules.Stations.Vie wStations' . ---> System.Web.HttpParseExcept ion: Could not load type 'PAAC.Modules.Stations.Vie wStations' . ---> System.Web.HttpParseExcept ion: Could not load type 'PAAC.Modules.Stations.Vie wStations' . ---> System.Web.HttpException: Could not load type 'PAAC.Modules.Stations.Vie wStations' . at System.Web.UI.TemplatePars er.GetType (String typeName, Boolean ignoreCase, Boolean throwOnError) at System.Web.UI.TemplatePars er.Process InheritsAt tribute(St ring baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) at System.Web.UI.TemplatePars er.PostPro cessMainDi rectiveAtt ributes(ID ictionary parseData) --- End of inner exception stack trace --- at System.Web.UI.TemplatePars er.Process Exception( Exception ex) at System.Web.UI.TemplatePars er.ParseSt ringIntern al(String text, Encoding fileEncoding) at System.Web.UI.TemplatePars er.ParseSt ring(Strin g text, VirtualPath virtualPath, Encoding fileEncoding) --- End of inner exception stack trace --- at System.Web.UI.TemplatePars er.ParseSt ring(Strin g text, VirtualPath virtualPath, Encoding fileEncoding) at System.Web.UI.TemplatePars er.ParseFi le(String physicalPath, VirtualPath virtualPath) at System.Web.UI.TemplatePars er.ParseIn ternal() at System.Web.UI.TemplatePars er.Parse() at System.Web.Compilation.Bas eTemplateB uildProvid er.get_Cod eCompilerT ype() at System.Web.Compilation.Bui ldProvider .GetCompil erTypeFrom BuildProvi der(BuildP rovider buildProvider) at System.Web.Compilation.Bui ldProvider sCompiler. ProcessBui ldProvider s() at System.Web.Compilation.Bui ldProvider sCompiler. PerformBui ld() at System.Web.Compilation.Bui ldManager. CompileWeb File(Virtu alPath virtualPath) at System.Web.Compilation.Bui ldManager. GetVPathBu ildResultI nternal(Vi rtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.Bui ldManager. GetVPathBu ildResultW ithNoAsser t(HttpCont ext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.UI.TemplateCont rol.LoadCo ntrol(Virt ualPath virtualPath) at DotNetNuke.UI.ControlUtili ties.LoadC ontrol[T]( TemplateCo ntrol containerControl, String ControlSrc) at DotNetNuke.UI.Modules.Modu leHost.Loa dModuleCon trol() --- End of inner exception stack trace ---
DotNetNuke.Services.Except
ASKER
this is my entire dataprovider.vb file
i am loosing my mind here trying to figure this one out
Imports System
Imports DotNetNuke
Namespace PAAC.Stations
''' -------------------------- ---------- ---------- ---------- ---------- ---------- -
''' <summary>
''' An abstract class for the data access layer
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' </history>
''' -------------------------- ---------- ---------- ---------- ---------- ---------- -
Public MustInherit Class DataProvider
#Region "Shared/Static Methods"
' singleton reference to the instantiated object
Private Shared objProvider As DataProvider = Nothing
' constructor
Shared Sub New()
CreateProvider()
Dim response As HttpResponse
response = System.Web.HttpContext.Cur rent.Respo nse
response.Write(objProvider )
response.Write("in sub new<br>")
' response.End()
End Sub
' dynamically create provider
Public Shared Sub CreateProvider()
Try
'Dim response As HttpResponse
'response = System.Web.HttpContext.Cur rent.Respo nse
'response.Write("(")
'response.Write(objProvide r)
'response.Write(")<br>")
'response.Write("before Reflection<br>")
' response.End()
'objProvider = DotNetNuke.Framework.Refle ction.Crea teObject(" data")
objProvider = CType(Framework.Reflection .CreateObj ect("data" , "PAAC.Stations.Data", ""), DataProvider)
'response.Write(objProvide r)
'response.Write("objprovid er<br>")
'response.Write("after Reflection<br>")
' response.End()
Catch ex As Exception
Throw ex
End Try
End Sub
' return the provider
Public Shared Shadows Function Instance() As DataProvider
' CreateProvider()
Return objProvider
End Function
#End Region
#Region "Abstract methods"
Public MustOverride Function GetPAACStationsByType(ByVa l type As String) As IDataReader
Public MustOverride Function GetPAACStationsByModule(By Val ModuleId As Integer) As IDataReader
Public MustOverride Function GetPAACStationInfo(ByVal ID As Integer) As IDataReader
Public MustOverride Function AddPAACStations(ByVal ID As Integer, ByVal ModuleID As Integer, ByVal StationName As String, ByVal type As String, ByVal location As String, ByVal directservice As String, ByVal connectingservice As String, ByVal parkandridelot As String, ByVal Amenities As String, ByVal lineorder As Integer) As Integer
Public MustOverride Sub UpdatePAACStations(ByVal ID As Integer, ByVal ModuleID As Integer, ByVal StationName As String, ByVal type As String, ByVal location As String, ByVal directservice As String, ByVal connectingservice As String, ByVal parkandridelot As String, ByVal Amenities As String, ByVal lineorder As Integer)
Public MustOverride Sub DeletePAACStations(ByVal ID As Integer)
#End Region
'Function GetStationsType(ByVal type As String) As IDataReader
' Throw New NotImplementedException
'End Function
'Function GetStationsByModuleID(ByVa l ModuleId As Integer) As IDataReader
' Throw New NotImplementedException
'End Function
'Function GetStationsInfo(ByVal ID As Integer) As IDataReader
' Throw New NotImplementedException
'End Function
'Sub AddStations(ByVal p1 As Integer, ByVal p2 As Integer, ByVal p3 As String, ByVal p4 As String, ByVal p5 As String, ByVal p6 As String, ByVal p7 As String, ByVal p8 As String, ByVal p9 As String, ByVal p10 As Integer)
' Throw New NotImplementedException
'End Sub
'Sub UpdateStations(ByVal p1 As Integer, ByVal p2 As Integer, ByVal p3 As String, ByVal p4 As String, ByVal p5 As String, ByVal p6 As String, ByVal p7 As String, ByVal p8 As String, ByVal p9 As String, ByVal p10 As Integer)
' Throw New NotImplementedException
'End Sub
'Sub DeleteStations(ByVal ID As Integer)
' Throw New NotImplementedException
'End Sub
End Class
End Namespace
i am loosing my mind here trying to figure this one out
Imports System
Imports DotNetNuke
Namespace PAAC.Stations
''' --------------------------
''' <summary>
''' An abstract class for the data access layer
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' </history>
''' --------------------------
Public MustInherit Class DataProvider
#Region "Shared/Static Methods"
' singleton reference to the instantiated object
Private Shared objProvider As DataProvider = Nothing
' constructor
Shared Sub New()
CreateProvider()
Dim response As HttpResponse
response = System.Web.HttpContext.Cur
response.Write(objProvider
response.Write("in sub new<br>")
' response.End()
End Sub
' dynamically create provider
Public Shared Sub CreateProvider()
Try
'Dim response As HttpResponse
'response = System.Web.HttpContext.Cur
'response.Write("(")
'response.Write(objProvide
'response.Write(")<br>")
'response.Write("before Reflection<br>")
' response.End()
'objProvider = DotNetNuke.Framework.Refle
objProvider = CType(Framework.Reflection
'response.Write(objProvide
'response.Write("objprovid
'response.Write("after Reflection<br>")
' response.End()
Catch ex As Exception
Throw ex
End Try
End Sub
' return the provider
Public Shared Shadows Function Instance() As DataProvider
' CreateProvider()
Return objProvider
End Function
#End Region
#Region "Abstract methods"
Public MustOverride Function GetPAACStationsByType(ByVa
Public MustOverride Function GetPAACStationsByModule(By
Public MustOverride Function GetPAACStationInfo(ByVal ID As Integer) As IDataReader
Public MustOverride Function AddPAACStations(ByVal ID As Integer, ByVal ModuleID As Integer, ByVal StationName As String, ByVal type As String, ByVal location As String, ByVal directservice As String, ByVal connectingservice As String, ByVal parkandridelot As String, ByVal Amenities As String, ByVal lineorder As Integer) As Integer
Public MustOverride Sub UpdatePAACStations(ByVal ID As Integer, ByVal ModuleID As Integer, ByVal StationName As String, ByVal type As String, ByVal location As String, ByVal directservice As String, ByVal connectingservice As String, ByVal parkandridelot As String, ByVal Amenities As String, ByVal lineorder As Integer)
Public MustOverride Sub DeletePAACStations(ByVal ID As Integer)
#End Region
'Function GetStationsType(ByVal type As String) As IDataReader
' Throw New NotImplementedException
'End Function
'Function GetStationsByModuleID(ByVa
' Throw New NotImplementedException
'End Function
'Function GetStationsInfo(ByVal ID As Integer) As IDataReader
' Throw New NotImplementedException
'End Function
'Sub AddStations(ByVal p1 As Integer, ByVal p2 As Integer, ByVal p3 As String, ByVal p4 As String, ByVal p5 As String, ByVal p6 As String, ByVal p7 As String, ByVal p8 As String, ByVal p9 As String, ByVal p10 As Integer)
' Throw New NotImplementedException
'End Sub
'Sub UpdateStations(ByVal p1 As Integer, ByVal p2 As Integer, ByVal p3 As String, ByVal p4 As String, ByVal p5 As String, ByVal p6 As String, ByVal p7 As String, ByVal p8 As String, ByVal p9 As String, ByVal p10 As Integer)
' Throw New NotImplementedException
'End Sub
'Sub DeleteStations(ByVal ID As Integer)
' Throw New NotImplementedException
'End Sub
End Class
End Namespace
You are creating your own mess here :)
couple of pointers:
* it would be good practice to use the same base namespace as the name of your assembly. So, you named your assembly PAAC.Modules.Stations, which means that the namespace you should use is also "PAAC.Modules.Stations"
* currently, your dataprovider sits in the namespace PAAC.Stations, which means that the instantiation should look like this: objProvider = CType(Framework.Reflection .CreateObj ect("data" , "PAAC.Stations", ""), DataProvider)
* make sure that both the abstract DataProvider class and the SQLDataProvider class are in the same namespace
And no: you cannot instantiate a provider without reflection... what would be the point in that?
couple of pointers:
* it would be good practice to use the same base namespace as the name of your assembly. So, you named your assembly PAAC.Modules.Stations, which means that the namespace you should use is also "PAAC.Modules.Stations"
* currently, your dataprovider sits in the namespace PAAC.Stations, which means that the instantiation should look like this: objProvider = CType(Framework.Reflection
* make sure that both the abstract DataProvider class and the SQLDataProvider class are in the same namespace
And no: you cannot instantiate a provider without reflection... what would be the point in that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
* what namespace is your concrete sqldataprovider in
* what is the name of the dll it is in.
* is the concrete sqldataprovider in the same dll as the rest of the module?