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.0Calling the DNN Api from another Win AppCalling the DNN Api from another Win App
Previous
 
Next
New Post
9/8/2006 10:44 AM
 

Hello,
I am trying to use the TabController API to create a series of pages automatically from another windows application. I am however, running into problems when I try and use the following line of code:

DataProvider provider = DotNetNuke.Data.DataProvider.Instance();

I get the exception :

System.TypeInitializationException was unhandled
  Message="The type initializer for 'DotNetNuke.Data.DataProvider' threw an exception."
  Source="DotNetNuke"
  TypeName="DotNetNuke.Data.DataProvider"
  StackTrace:
       at DotNetNuke.Data.DataProvider.Instance()
       at ENERG.VEM.DNN.VEMS_DNN_Synchroniser..ctor() in C:\Code\VEMS2005\DNN_VEM_BusinessLogic\VEMS_DNN_Synchroniser.cs:line 24
       at EnergAnalysisHostApp.Form1.btnDNN_Click(Object sender, EventArgs e) in C:\Code\VEMS2005\EnergAnalysisHostApp\Form1.cs:line 189
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at EnergAnalysisHostApp.Form1.Main() in C:\Code\VEMS2005\EnergAnalysisHostApp\Form1.cs:line 141
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

I expect this is to do with Reflection and inability for it to create the SqlDataProvider concrete class, but I do now know how to tell DNN which data provider to use. I have guessed that the app.config file is the place to do it in the section called: <data> which I have attempted to mimic in the windows's app.config by copying most of the web.config into it.

 

<data defaultProvider="SqlDataProvider">

<providers>

<clear/>

<add name="SqlDataProvider" type="DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider" connectionStringName="SiteSqlServer" upgradeConnectionString="" providerPath="c:\code\dnn\Providers\DataProviders\SqlDataProvider\" objectQualifier="" databaseOwner="dbo"/>

</providers>

</data>

Does anyone have any suggestions, or I am unable to do what I am trying to do?

Best regards,

Chris.

 

 
New Post
9/8/2006 12:26 PM
 

You'll need to also add the section name in the "configSections" element of app.config like this:

      <section name="data" requirePermission="false" type="DotNetNuke.Framework.Providers.ProviderConfigurationHandler, DotNetNuke"/>

Nik

 


Nik Kalyani
Co-founder
DotNetNuke Corporation
Blog | Twitter | FaceBook
 
New Post
9/11/2006 3:40 AM
 

Thanks Nik,

This is my entire app.config file as I have it now, I started off, with the entire web.config file placed into my app.config file. But not I have cut it back to (see end of post) .

 

Are there other examples out there on how to call the API from NON-WEB project?

 

 

Regards, Chris.

 

The code I am executing is:

public VEMS_DNN_Synchroniser()

{

mController = new TabController();

mPortalID = 0;

DataProvider provider = DotNetNuke.Data.DataProvider.Instance();

mHome = mController.GetTabByName("Home", mPortalID);

}

The exception I get is :

System.TypeInitializationException was unhandled
  Message="The type initializer for 'DotNetNuke.Data.DataProvider' threw an exception."
  Source="DotNetNuke"
  TypeName="DotNetNuke.Data.DataProvider"
  StackTrace:
       at DotNetNuke.Data.DataProvider.Instance()
       at ENERG.VEM.DNN.VEMS_DNN_Synchroniser..ctor() in C:\Code\VEMS2005\DNN_VEM_BusinessLogic\VEMS_DNN_Synchroniser.cs:line 25
       at EnergAnalysisHostApp.Form1.btnDNN_Click(Object sender, EventArgs e) in C:\Code\VEMS2005\EnergAnalysisHostApp\Form1.cs:line 189
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at EnergAnalysisHostApp.Form1.Main() in C:\Code\VEMS2005\EnergAnalysisHostApp\Form1.cs:line 141
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

 

 

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<!-- register local configuration handlers -->

<configSections>

<sectionGroup name="dotnetnuke">

<section name="data" requirePermission="false" type="DotNetNuke.Framework.Providers.ProviderConfigurationHandler, DotNetNuke"/>

</sectionGroup>

</configSections>

<connectionStrings>

<add name="SiteSqlServer" connectionString="Server=brighton;Database=DotNetNukeDevelopment;uid=dnn;pwd=dnn;" providerName="System.Data.SqlClient"/>

</connectionStrings>

<appSettings>

<add key="SQLConnectionString" value="User Id=dnnapp;Password=dnnApp;data source=brighton;initial catalog=vem" />

<add key="SiteSqlServer" value="Server=brighton;Database=DotNetNukeDevelopment;uid=dnn;pwd=dnn;"/>

</appSettings>

</configuration>

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Calling the DNN Api from another Win AppCalling the DNN Api from another Win App


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