I looked at the IWeb code and created a test Windows Form and I did not get any promising results. My suspicion is that because a WebService runs within a web application context, it has availaible to it the same things a module has, making it easy to call the DNN DAL and/or Methods.
When I looked through the IWeb code, I did not see anything that I was not expecting, IWeb does work nicely. To access the DNN Core DAL It looks like IWeb is importing DotNetNuke and make a call to DotNetNuke.Data.DataProvider.Instance() or some other method and away you go (Am I missing something?). When loading a Windows Form, the DataProvider.Instance(), and a whole bunch of other DNN stuff, does not get initialized, no web.config file etc. So all of these methods/initializations returns on error like.
The type initializer for 'DotNetNuke.Data.DataProvider' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at DotNetNuke.Framework.Reflection.CreateObject(String ObjectProviderType, String ObjectProviderName, String ObjectNamespace, String ObjectAssemblyName, Boolean UseCache)
at DotNetNuke.Data.DataProvider.CreateProvider()
at DotNetNuke.Data.DataProvider..cctor()
--- End of inner exception stack trace ---
at DotNetNuke.Entities.Portals.PortalController.GetPortals()
Wanting to be complete as possibile I created a Windows Form with a listbox and a button and this code, taken mostly from IWeb. It returns the error above on load and after hitting the button a very similar one.
Imports System
Imports System.Web 'Not sure why it even lets me do this-Maybe the key is here
Imports System.Data
Imports System.Reflection
Imports System.Collections.Generic
Imports DotNetNuke
Imports DotNetNuke.Security.Roles
Imports DotNetNuke.Security.Membership
Public Class MainForm
Private Sub btnResetCache_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
DotNetNuke.Common.Utilities.DataCache.ClearPortalCache(0, True)
End Sub
Private Sub MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
PortalList()
End Sub
Private Function PortalList() As List(Of IWebPortalInfo)
Dim colPortalList As New List(Of IWebPortalInfo)
Dim colPortalController As New DotNetNuke.Entities.Portals.PortalController()
Dim colPortalInfo As DotNetNuke.Entities.Portals.PortalInfo
Dim arrArraylist As ArrayList
arrArraylist = colPortalController.GetPortals()
For Each colPortalInfo In arrArraylist
Dim objIWebPortalInfo As New IWebPortalInfo()
objIWebPortalInfo.PortalID = colPortalInfo.PortalID
objIWebPortalInfo.PotalName = "Portal: [" & CStr(colPortalInfo.PortalID) & "] " & colPortalInfo.PortalName
'New addition
LbProcs.Items.Add(objIWebPortalInfo.PotalName)
colPortalList.Add(objIWebPortalInfo)
Next
Return colPortalList
End Function
End Class
Public Class IWebPortalInfo
Private _PortalID As Integer
Private _PotalName As String
' initialization
Public Sub New()
End Sub
' public properties
Public Property PortalID() As Integer
Get
Return _PortalID
End Get
Set(ByVal Value As Integer)
_PortalID = Value
End Set
End Property
Public Property PotalName() As String
Get
Return _PotalName
End Get
Set(ByVal Value As String)
_PotalName = Value
End Set
End Property
End Class
I Hope I have miseed something or I am making this harder than it has to be. Any and all feedback is appreciated.