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 Community Exchange, where community members ask and answer questions about DNN. To get started, just start typing your question below and either select one of the suggested questions or ask a new question of your own.

nullreference exception when using the ModuleController.GetModule(int moduleid) method

Return to previous page

  • 7/1/2015
  • 1290 Views

Question:

Robert Solovy 9 years ago

My code does the following

                DotNetNuke.Entities.Modules.ModuleController moduleController = new DotNetNuke.Entities.Modules.ModuleController();

if (moduleController != null) { var requestedModule = moduleController.GetModule(moduleid); ... }


I get a nullreferenceexception on the line inside the if even though the moduleController is not null, so I'm assuming it has something to do with the internals of the GetModule method. Any help would be much appreciated.

Thanks.

Top Answer:

Michael Tobisch 9 years ago

Have you checked if moduleID has a value at that stage and if the value has a correspnding record in the Modules table?

Happy DNNing!
Michael

Sign In to Participate
Or register to become a member