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#.
- Project 1: A custom module
- Project 2: A general DLL which contains several classes for handling common tasks
- Facebook Class
- DNNCore class (custom error log writing among other things to come)
- 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