Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

PortalWebHosting
  Ads  
Iron Speed Designer is a software development tool for building database, reporting, and forms applications for .NET without hand-coding.
 


  Sponsors  

Meet Our Sponsors

The Official Microsoft ASP.NET Website
Portal Webhosting - Hosting For Developers
Red-Gate Software
MaximumASP
SourceGear - Tools for Developers
.: CounterSoft :.
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  Calling the DNN Api from another Win App
Previous Previous
 
Next Next
New Post 9/8/2006 8:44 AM
User is offline Chris Inkpen
2 posts
10th Ranked


Calling the DNN Api from another Win App 

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 10:26 AM
User is offline Nik Kalyani
706 posts
www.dotnetnuke.com
7th Ranked








Re: Calling the DNN Api from another Win App 

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 Corp.
Blog | FriendFeed | FaceBook
 
New Post 9/11/2006 1:40 AM
User is offline Chris Inkpen
2 posts
10th Ranked


Re: Calling the DNN Api from another Win App 

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 Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  Calling the DNN Api from another Win App
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


Swanzey Internet Group LLC
DotNetNuke design, development, e-Commerce, hosting, maintenance, and training. Exclusively DotNetNuke.
www.swanzey.com
Lucede Systems Group
Providing a full range of IT services for large and medium sized companies
www.lucede.com
Adaptive InfoSystems, Inc.
We provide custom programming and various levels of support for DotNetNuke and the .Net framework.
www.aisysweb.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP