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

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Module Communication throws NullReferenceException in IEModule Communication throws NullReferenceException in IE
Previous
 
Next
New Post
9/16/2008 4:23 AM
 

Hi all

I'm currently using ModuleCommunication to get a shopping cart module to update its list of items when the button is clicked on the details page.  I can get this to work in Firefox but in IE i get the error: Object reference not set to an instance of an object.  This refers to the method ModuleCommunication(this, args).

Strange that this only happens in one browser.  Any help would be much appreciated.

Si

 
New Post
9/16/2008 5:32 AM
 

Hi

Realised the error has nothing to do with IE or Firefox but wether you are logged in as an Admin or not.  Regular visitors get an error but for the admin it works perfectly.  Any idea what I could be doing wrong?

Si

 
New Post
9/16/2008 9:03 AM
 

Hi Si,

When raising events in C#, you are required to ensure that the event is not null before raising it.  The basic pattern* is this:

if(ModuleCommunication != null)

      ModuleCommunication(this, args);

The only way you could be generating that error on that line would be if ModuleCommunication were null, so this would appear to be the source of your problem. 

Once that is corrected, you will need to figure out why your receiver is not subscribing to the communication event when you are not logged in as an administrator.  Probably the most common cause of this would be the receiving module not being displayed on the page due to permissions.  Are you able to see both modules -- on the same page -- when not logged in as admin?

Hope this gets you started!

Brandon

* There is actually an interesting race condition in this pattern such that you risk failure under some multithreading situations.  This is an ongoing  weakness in C# and the solutions (even the local variable version) are neither elegant nor satisfactory.  Google for more information; the above pattern is fine for most situations.


Brandon Haynes
BrandonHaynes.org
 
New Post
9/16/2008 9:31 AM
 

Theres already some checking done for a null value but i use a try statement.  I had also made sure all the modules were visible to both admin and regular users. All the permissions on every page are the same and set to All Users.

I would have thought ModuleCommunication is null due to some sort of user privelidge issue, as the only time this happens is when you are not logged in. So testing for this is pointless as the catch statement will just display a null reference error and it wont help me figure out why this is happening in the slightest.  Are there any other known issues using IMC as a regular user? I heard mentioned in another forum that you must be logged in for IMC to work.  Is this true?

 
New Post
9/17/2008 4:34 AM
 

Some more info on the problem:

I have a search results page and a details page.  On both there is a button to add an item to the shopping cart.  It does this by using IMC.  So when 'Add to cart' is pressed on either the results page or details page it runs ModuleCommunication(this,args).  Here is where it gets strange.

If you are logged in as admin both the buttons work and send the correct data to the shopping cart module. When loged in as a regular user or not logged in at all only the results page button works. The details page just throws a NullReferenceException. 

Other info:

  • The results page creates a session which holds our search results and item information.
  • The details page loads this session variable to access this info
  • The ModuleCommunicationEventArgs object just holds a string
  • ShoppingCart module also loads the session variable and another session holding the cart contents.
  • All coded in C#

Hopefully this can shed some light on the problem.

Si

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Module Communication throws NullReferenceException in IEModule Communication throws NullReferenceException in IE


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