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

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsProvidersProvidersDataProvider ErrorDataProvider Error
Previous
 
Next
New Post
1/18/2010 4:04 AM
 

I am building a module ('MyModule') in which a user can set a few parameters for a calculation job.
The calculation job is then saved to a table in the DotNetNuke database.
A windows service on my machine ('MyService') checks this table every couple of minutes and if there are any jobs to be calculated, calculates them.

In my solution file there is one project that is MyModule. In another project file (in the same solution) the windows service is implemented.
MyModule has it's own namespace. The same goes for MyService. I've got a reference from MyService to MyModule.

A JobController.vb and a JobInfo.vb class are implemented in MyModule. But I need those in MyService too. I can initialize the JobController in MyService.
Only when I try to call a method ('GetNonCalculatedJobs') it returns the following error message: "The type initializer for 'MyCompany.MyModule.DataProvider' threw an exception." (The same method works fine when it resides in MyModule.)

I don't have a clue what causes this error message. Any help is greatly appreciated!


The complete error message is:
----------------------------------------------------------------------------------
System.TypeInitializationException was unhandled by user code
  Message="The type initializer for 'MyCompany.MyModule.DataProvider' threw an exception."
  Source="MyCompany.MyModule"
  TypeName="MyCompany.MyModule.DataProvider"
  StackTrace:
       at MyCompany.MyModule.DataProvider.Instance()
       at MyCompany.MyModule.JobController.GetNonCalculatedJobs() in D:\DotNetNuke\DesktopModules\MyModule\Components\JobController.vb:line 107
       at MyService.MyService.JobTimer_Elapsed(Object sender, ElapsedEventArgs e) in D:\DotNetNuke\DesktopModules\MyService\MyService.vb:line 34
       at System.Timers.Timer.MyTimerCallback(Object state)
  InnerException: System.NullReferenceException
       Message="Object reference not set to an instance of an object."
       Source="DotNetNuke"
       StackTrace:
            at DotNetNuke.Framework.Reflection.CreateObject(String ObjectProviderType, String ObjectProviderName, String ObjectNamespace, String ObjectAssemblyName, Boolean UseCache)
            at DotNetNuke.Framework.Reflection.CreateObject(String ObjectProviderType, String ObjectNamespace, String ObjectAssemblyName)
            at MyCompany.MyModule.DataProvider.CreateProvider() in D:\DotNetNuke\DesktopModules\MyModule\Components\DataProvider.vb:line 49
            at MyCompany.MyModule.DataProvider..cctor() in D:\DotNetNuke\DesktopModules\MyModule\Components\DataProvider.vb:line 44
       InnerException:
----------------------------------------------------------------------------------

 
New Post
1/18/2010 8:31 AM
 

My question put simpler:

how can I use the DotNetNuke (SQL)Dataprovider in another project?

 
New Post
1/18/2010 10:06 AM
 

Hi Gvdamn,

The error you're reporting is a result of DotNetNuke (or .NET reflection) not being able to find the assembly or class that you're trying to load.  The most likely cause of this error is a malformed (or missing) web.config or app.config metadata for the data provider class in question.  It is also possible that the assembly in question is not in the bin directory of the second project.

Although it is possible to utilize the data provider model in an external application, this tends to be a laborious issue to debug and get configured exactly correctly.  It is also difficult to give precise guidance with respect to exactly how you should be proceeding.  This is probably why your previous queries haven't received any responses (it's not because we don't want to help!).

If I were in your shoes, I would download and deploy the DotNetNuke debug-symbol assemblies to get a better idea where your actual problem was occurring.  Actual line numbers of the underlying error might aid us in better-assisting you.  I'd also probably debug the application using the source-version of DotNetNuke core so I could step into the relevant functions to see exactly where things were going awry (I expect it's the "big" CreateObject method, or perhaps in ProviderConfiguration).

Hope this helps!

Brandon


Brandon Haynes
BrandonHaynes.org
 
New Post
1/18/2010 10:57 AM
 

Thank you for your answer Brandon.

Brandon Haynes wrote:
The error you're reporting is a result of DotNetNuke (or .NET reflection) not being able to find the assembly or class that you're trying to load.  The most likely cause of this error is a malformed (or missing) web.config or app.config metadata for the data provider class in question.  It is also possible that the assembly in question is not in the bin directory of the second project.

I guess the first option is less likely because my second project is a Windows service.

When you refer to assembly do you mean the assembly of MyModule or of the (SQL)DataProvider?

The "MyCompany.MyModule.dll" file is in the bin\Debug directory of the MyService project directory.

Brandon Haynes wrote:
If I were in your shoes, I would download and deploy the DotNetNuke debug-symbol assemblies to get a better idea where your actual problem was occurring.  Actual line numbers of the underlying error might aid us in better-assisting you.  I'd also probably debug the application using the source-version of DotNetNuke core so I could step into the relevant functions to see exactly where things were going awry (I expect it's the "big" CreateObject method, or perhaps in ProviderConfiguration).

Are the DotNetNuke debug-symbol assemblies which I found here

http://blogs.law.harvard.edu/brandonh...

compatible with version 5.1.4 of DNN?

 
New Post
1/18/2010 11:10 AM
 

Hi Gvdamn,

If you're running a windows service, you'll need to make sure you include the relevant provider metadata from the configuration/dotnetnuke section of your web.config.  Without this metadata (e.g. configuration/dotnetnuke/data), I would expect to see the error you are reporting.

The SqlDataProvider assembly (and the DotNetNuke assembly) will also need to be deployed with your windows service.

Note that while you're debugging this stuff, you can always bypass the data abstraction layer directly and just directly instantiate the SqlDataProvider, although this would come at the expense of layer abstraction.

Finally, the DotNetNuke platform now includes a debug symbol release for this sort of problem; that's why I refrained from distributing new debug builds to the community.  The symbols may be found here.  I suspect I already know where your application is failing (e.g. erroneous configuration or missing assemblies), so this may be of limited use.  Focusing on fixing the above issues will likely be your best use of time.

Hope this helps!

Brandon 

EDIT: I forgot that the symbol release started in 5.2, and not 5.1.4.  Since I'm not aware of any symbol release for 5.1.4, I recommend looking at the app.config and assembly issues I described above.


Brandon Haynes
BrandonHaynes.org
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsProvidersProvidersDataProvider ErrorDataProvider Error


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