Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > DotNetNuke > BOOK: Professional DotNetNuke Module Programming ISBN: 978-0-470-17116-5
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional DotNetNuke Module Programming ISBN: 978-0-470-17116-5
This is the forum to discuss the Wrox book Professional DotNetNuke Module Programming by Mitchel Sellers and Shaun Walker - Wrox DotNetNuke Series Editor; ISBN: 978-0-470-17116-5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional DotNetNuke Module Programming ISBN: 978-0-470-17116-5 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 5th, 2011, 04:32 AM
Registered User
 
Join Date: May 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Angry problem with add web user control to Class library project

I'm trying to create a DNN module by creating a class library.

but something is wrong when I add a web user control to my project:( I explained all of my actions:)



1- file > new project > VB class library ( path : desktopModules) ( project name is:TestProj)

2- delete class1.vb from my project

3- add two references:
DotNetNuke.dll
Microsoft.ApplicationBlocks.Data.dll

4- add new folder : Components , and add 4 classes to it:

DataProvider.vb

Code:
			Imports System
			Imports DotNetNuke

			Namespace TestProj


				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()
					End Sub

					' dynamically create provider
					Private Shared Sub CreateProvider()
						objProvider = CType(Framework.Reflection.CreateObject("data", "TestProj", ""), DataProvider)
					End Sub

					' return the provider
					Public Shared Shadows Function Instance() As DataProvider
						Return objProvider
					End Function

			#End Region

			#Region "Abstract methods"

					Public MustOverride Sub AddContact(ByVal Code As Integer)
					Public MustOverride Sub DeleteContact(ByVal Code As Integer)
					Public MustOverride Sub UpdateContact(ByVal Code As Integer)
					Public MustOverride Function GetContact(ByVal Code As Integer) As IDataReader
					Public MustOverride Function GetsContacts(ByVal Code As Integer) As IDataReader
			#End Region

				End Class

			End Namespace
SqlDataProvider.vb

Code:
			Imports System
				Imports System.Data
				Imports System.Data.SqlClient
				Imports Microsoft.ApplicationBlocks.Data

				Imports DotNetNuke.Common.Utilities
				Imports DotNetNuke.Framework.Providers

				Namespace TestProj

					Public Class SqlDataProvider

						Inherits DataProvider

				#Region "Private Members"

						Private Const ProviderType As String = "data"
						Private Const ModuleQualifier As String = "YourCompany_"

						Private _providerConfiguration As ProviderConfiguration = ProviderConfiguration.GetProviderConfiguration(ProviderType)
						Private _connectionString As String
						Private _providerPath As String
						Private _objectQualifier As String
						Private _databaseOwner As String

				#End Region

				#Region "Constructors"

						Public Sub New()

							' Read the configuration specific information for this provider
							Dim objProvider As Provider = CType(_providerConfiguration.Providers(_providerConfiguration.DefaultProvider), Provider)

							' Read the attributes for this provider

							'Get Connection string from web.config
							_connectionString = Config.GetConnectionString()

							If _connectionString = "" Then
								' Use connection string specified in provider
								_connectionString = objProvider.Attributes("connectionString")
							End If

							_providerPath = objProvider.Attributes("providerPath")

							_objectQualifier = objProvider.Attributes("objectQualifier")
							If _objectQualifier <> "" And _objectQualifier.EndsWith("_") = False Then
								_objectQualifier += "_"
							End If

							_databaseOwner = objProvider.Attributes("databaseOwner")
							If _databaseOwner <> "" And _databaseOwner.EndsWith(".") = False Then
								_databaseOwner += "."
							End If

						End Sub

				#End Region

				#Region "Properties"

						Public ReadOnly Property ConnectionString() As String
							Get
								Return _connectionString
							End Get
						End Property

						Public ReadOnly Property ProviderPath() As String
							Get
								Return _providerPath
							End Get
						End Property

						Public ReadOnly Property ObjectQualifier() As String
							Get
								Return _objectQualifier
							End Get
						End Property

						Public ReadOnly Property DatabaseOwner() As String
							Get
								Return _databaseOwner
							End Get
						End Property

				#End Region

				#Region "Private Methods"

						Private Function GetFullyQualifiedName(ByVal name As String) As String
							Return DatabaseOwner & ObjectQualifier & ModuleQualifier & name
						End Function

						Private Function GetNull(ByVal Field As Object) As Object
							Return DotNetNuke.Common.Utilities.Null.GetNull(Field, DBNull.Value)
						End Function

				#End Region

				#Region "Public Methods"
						Public Overrides Sub DeleteContact(ByVal Code As Integer)
							SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "judiciary_DeleteContact", Code)
						End Sub

						Public Overrides Function GetContact(ByVal Code As Integer) As System.Data.IDataReader
							Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "judiciary_GetContact", Code), IDataReader)
						End Function

						Public Overrides Function GetsContacts(ByVal Code As Integer) As System.Data.IDataReader
							Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & "judiciary_GetsContacts", Code), IDataReader)
						End Function

						Public Overloads Overrides Sub AddContact(ByVal Code As Integer)
							SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "judiciary_AddContact", Code)
						End Sub

						Public Overloads Overrides Sub UpdateContact(ByVal Code As Integer)
							SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "judiciary_UpdateContact", Code)
						End Sub
						
				#End Region

					End Class

				End Namespace
TestProjInfo.vb

Code:
			Imports System
			Imports System.Configuration
			Imports System.Data

			Namespace TestProj
				Public Class TestProjInfo
					Private _Code As Integer
					Public Property Code() As Integer
						Get
							Return _Code
						End Get
						Set(ByVal Value As Integer)
							_Code = Value
						End Set
					End Property

						End Class

			End Namespace
TestProjController.vb

Code:
			Imports System
			Imports System.Configuration
			Imports System.Data
			Imports System.Xml
			Imports System.Web
			Imports System.Collections.Generic

			Imports DotNetNuke
			Imports DotNetNuke.Common
			Imports DotNetNuke.Common.Utilities.XmlUtils
			Imports DotNetNuke.Common.Utilities
			Imports DotNetNuke.Services.Search

			Namespace TestProj
				Public Class TestProjtProjController


			#Region "Public Methods"

					Public Sub AddContact(ByVal c As TestProjInfo)
						DataProvider.Instance.AddContact(c.Code)
					End Sub
					Public Sub DeleteContact(ByVal Code As Integer)
						DataProvider.Instance.DeleteContact(Code)
					End Sub
					Public Sub UpdateContact(ByVal c As TestProjInfo)
						DataProvider.Instance.UpdateContact(c.Code)
					End Sub
					Public Function GetContact(ByVal Code As Integer) As TestProjInfo
						Return CType(DotNetNuke.Common.Utilities.CBO.FillObject(DataProvider.Instance().GetContact(Code), GetType(TestProjInfo)), TestProjInfo)
					End Function
					Public Function GetsContacts(ByVal Code As Integer) As ArrayList
						Return CType(DotNetNuke.Common.Utilities.CBO.FillCollection(DataProvider.Instance().GetsContacts(Code), GetType(TestProjInfo)), ArrayList)
					End Function
			#End Region

				End Class
			End Namespace

Until this point I can build my solution successfully . my problem is on add web user control:

5- add new project: asp.net web application and add a web user control to it(ie to my web applicatio proj)

6- drag the WUC.ascx and drop into TestProj ,
first change to WUC.ascx: Inherits="WebApplication2.WUC" ==> Inherits="TestProj.WUC"
second, I changed the WUC.ascx.vb as follows:

Code:
			Imports DotNetNuke

				Namespace TestProj
					Partial Public Class WUC
						Inherits Entities.Modules.PortalModuleBase


						Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

						End Sub

					End Class
				End Namespace
and then add system.web.dll to my references ( and delete web application from project)

7- build solution succeeded!

BUT: when I double click on my WUC.ascx to see WUC.ascx.vb I encounter the message alert that: " could not complete the action"

In addition when I want to add this control to my DNN portal it says that:



Error: TEST is currently unavailable.
DotNetNuke.Services.Exceptions.ModuleLoadException : Could not load type 'TestProj.WUC'. --->
System.Web.HttpParseException: Could not load type 'TestProj.WUC'. ---> System.Web.HttpParseException: Could not
load type 'TestProj.WUC'. ---> System.Web.HttpException: Could not load type 'TestProj.WUC'. at System.Web.UI.TemplateParser
.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError) at System.Web.UI.TemplateParser.ProcessInheritsAttrib ute
(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) at System.Web.UI.TemplateParser
.PostProcessMainDirectiveAttributes(IDictionary parseData) --- End of inner exception stack trace --- at System
.Web.UI.TemplateParser.ProcessException(Exception ex) at System.Web.UI.TemplateParser.ParseStringInternal(S tring text, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
--- End of inner exception stack trace --- at System
.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) at System.Web.UI.TemplateParser
.ParseFile(String physicalPath, VirtualPath virtualPath) at System.Web.UI.TemplateParser.ParseInternal()
at System.Web.UI.TemplateParser.Parse() at System.Web.Compilation.BaseTemplateBuildProvider.g et_CodeCompilerType()
at System.Web.Compilation.BuildProvider.GetCompilerTy peFromBuildProvider(BuildProvider buildProvider) at
System.Web.Compilation.BuildProvidersCompiler.Proc essBuildProviders() at System.Web.Compilation.BuildProvidersCompiler.
PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile (VirtualPath virtualPath) at System.Web.Compilation.
BuildManager.GetVPathBuildResultInternal(VirtualPa th virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVPathBuildR esultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean
allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.UI.TemplateControl.LoadControl(VirtualP ath virtualPath)
at DotNetNuke.UI.ControlUtilities.LoadControl[T](TemplateControl containerControl, String ControlSrc) at DotNetNuke.UI.Modules.ModuleHost
.LoadModuleControl() --- End of inner exception stack trace ---


what is wrong ?

Last edited by hamed88; May 7th, 2011 at 08:34 AM.
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing and Executing js in class library project indiandotnet C# 2008 aka C# 3.0 0 September 19th, 2008 09:56 AM
Add Windows User control in Web User Control agarwalvidhu C# 0 March 30th, 2006 01:17 AM
Can not add web user control in VS.Net sn00pyg4rfi3ld VS.NET 2002/2003 2 June 1st, 2005 04:29 AM
Controls New Class Library project page 60??? Ghistos BOOK: ASP.NET Website Programming Problem-Design-Solution 5 July 27th, 2004 11:40 PM
New project, VB.NET Class Library eirikr BOOK: ASP.NET Website Programming Problem-Design-Solution 0 June 11th, 2003 06:25 PM



All times are GMT -4. The time now is 03:20 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.