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 ExtensionsModulesModulesPassing PortalModuleBase class?Passing PortalModuleBase class?
Previous
 
Next
New Post
1/18/2012 8:34 PM
 

Ok, I'll admit it up front...I am a self-trained coding hack...I start with examples and then modify them and hopefully get them to work. As I've progressed, I've learned more, but still lack some of the basics concepts of OO programming. And on top of that I am taking my 15 years +/- of vb/asp experience and now moving to C#. So given that, here is my question.

I am creating several custom modules and found that it would be good to have a common dll that I can build to have all the standard type stuff in it I'd want for building my modules...one of these is a class for Facebook interface, another for DNN core stuff (writing to the error logs), and another DNN specific class for for creating users. It seems I've been able to get the Facebook and DNN User creation ones working ok...but what I thought would be the easy one, I am stuck on.

I read this article from Bruce Chapman about writing your own custom log entries. So heck, I want to put that into my general class.

So now I am trying to implement it. I have the following set up in C#.

  1. Project 1: A custom module
  2. Project 2: A general DLL which contains several classes for handling common tasks
    1. Facebook Class
    2. DNNCore class (custom error log writing among other things to come)
    3. DNNSecurity class (creates users programmatically and adds them to roles)

I want the Project 1: Custom Module to do somthing with the Facebook class. It calls a method in that class, from within that class if there is an unhandled exception, I want to call my custom dnn log writing method in my DNNCore class...

So I'm starting by trying to use the base DNN error logging method call: DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); from within my Facebook class. So from my custom module, I need to pass an instance of "this" (which refers to PortalModuleBase) from my module to my Facebook class. If I can get this to work, I then will need to pass it from there to the DNN Core class to actually do the custom logging I want to do. But I can't get this to work.

CALL FROM MY MODULE:

var FBAccessToken = FacebookSDKInterface.GetFBAccessToken(this, RedirectURL, CurrentURL);

FACEBOOK CLASS (separate project and DLL)

public string GetFBAccessToken(PortalModuleBase SourceClass, string FBRedirectURL, string FBResultURL)
        {

            try
            { GET FACEBOOK CODE HERE - Removed for brevity, as if though that is possible at this point :)

                        return accessToken;


                    }  //result.IsSuccess = True
                    else
                    {"
                        RETURN "ERROR MESSAGE"

                    } //result.IsSuccess = False
                } //FacebookOAuthResult.TryParse

                return "Facebook convert code to AccessToken didn't work....sup with that?";
                
            } //Try
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(SourceClass, ex);

                return "Hmmm, there was some unhandled error with the GetFBAccessToken method. Check the log files. <br />" + ex.Message;
            } //Catch

        } //Method: GetFBAccessToken

The error I am getting is in my MODULE on the call to the Facebook method. The error is: "An Object Reference is required for a non-static field, method. or property."

Can somebody help a brother out? What am I doing wrong here?

Thanks so much in advance?

Chad

 
New Post
1/19/2012 4:38 AM
 
Personally, you have a few options, i don't necessarily think you want to be passing those references all around. There is a different method for logging, DOtNetNuke.Services.Exceptions.Exceptions.LogException that allows you to write it out.

Otherwise, I think we might need to see how you are making the call to you FB class.

-Mitchel Sellers
Microsoft MVP, ASPInsider, DNN MVP
CEO/Director of Development - IowaComputerGurus Inc.
LinkedIn Profile

Visit mitchelsellers.com for my mostly DNN Blog and support forum.

Visit IowaComputerGurus.com for free DNN Modules, DNN Performance Tips, DNN Consulting Quotes, and DNN Technical Support Services
 
New Post
1/24/2012 3:31 PM
 
Thanks Mitchel for the reply. For now, I have taken a different approach, but I may re-visit this later.
P.S. I love your book, it has been my enabler!
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesPassing PortalModuleBase class?Passing PortalModuleBase class?


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