Click here to Skip to main content
15,915,163 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

I have a multi-project web application which is calling, in its Global.asax, a static method on a class.
This call generates a null reference exception. The exception is not caused (as far as I know) by anything inside the method itself but merely by the method call (I assume this simply on the basis that , by putting a breakpoint on the very first line in the method, the breakpoint is never reached).
I have a
<compilation debug="true" 
setting in the <system.web> section of the web application web.config.
Can it be related to the fact that the class whose static method I am trying to call is declared in a different project (in the same solution) from the calling project ?
Maybe anything related to the debug configuration ?

This is the essential part of the code :

web application solution

web application project (Global.Asax.cs):

using BLL;
namespace Agenda2
{

 public class MvcApplication : System.Web.HttpApplication
 {
      ......................................
      protected void  SessionStart ()
      {
         BLL_Configuration.readParameter() ;

         ..................          
      }
      ......................


 }

}
Business Logic Project :

namespace BLL
{
public class BLL_Configuration {

       public static void readParameter()
       {
            .........
       }

}


What I have tried:

Tried commenting any code in the called method
Posted
Updated 25-Apr-18 23:58pm
Comments
OriginalGriff 26-Apr-18 5:35am    
Answer updated.

1 solution

Then you need to use the debugger better - start with the calling method, and make sure you get to the call.
Until you can get to a breakpoint that works, you can't even start looking for the null value without adding piles of logging code to your app to find out what value is null when it shouldn't be.

And sorry - but we can't do that for you!

Quote:
I do reach the method call (that is the
BLL_Configuration.readParameter() ;

line);
whenever I try to step in or step over I get the exception.
By the way , if I put a breakpoint on the first line of code
of the
readParameter
method, this is never reached.


So check three things:
1) Is there a static constructor for the BLL_Configuration class? If so, breakpoint that.
2) Does the BLL_Configuration class contain any static variables with initial values? Do any of those depend on other things? Could any of the initializers be throwing the exception?
3) Does the exception include file and / or line information? It usually does...

Remember that static initialization will occur before any static method is called, so it's very likely that the problem is somewhere there.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900