Saturday, October 2, 2010

NullReferenceException on GetEntryAssembly

I'm following an MVC lesson from Steven Sanderson book. There's an error which eludes me, but solved by just changing the erring function to other equivalent function.


Server Error in '/SportsStore' Application.


Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 39:             
Line 40: 
Line 41:             var controllerTypes = from t in Assembly.GetEntryAssembly().GetTypes()
Line 42:                                   where typeof(IController).IsAssignableFrom(t)
Line 43:                                   select t;






That problem can be solved by changing GetEntryAssembly to GetExecutingAssembly

No comments:

Post a Comment