Null reference exception in build

Hi all, i get a null reference exception in build. Could you tell me what might cause this ? I searched a lot, but couln’t find a proper solution.
Thanks is advance.

This is the output log

Output.Log

Initialize engine version: 2017.2.0p2 (dbc2eb12ac98)
GfxDevice: creating device client; threaded=1
Direct3D:
Version: Direct3D 11.0 [level 11.0]
Renderer: NVIDIA GeForce GT 540M (ID=0xdf4)
Vendor: NVIDIA
VRAM: 978 MB
Driver: 21.21.13.7633
Begin MonoManager ReloadAssembly

  • Completed reload, in 0.101 seconds
    Initializing input.

Input initialized.

Initialized touch support.

Setting up 2 worker threads for Enlighten.
Thread → id: 17d0 → priority: 1
Thread → id: 570 → priority: 1
UnloadTime: 2.474706 ms
Unloading 5 Unused Serialized files (Serialized files now loaded: 0)
UnloadTime: 3.684394 ms

Unloading 16 unused Assets to reduce memory usage. Loaded Objects now: 15013.
Total: 7.235370 ms (FindLiveObjects: 1.217273 ms CreateObjectMapping: 0.277099 ms MarkObjects: 5.684328 ms DeleteObjects: 0.055776 ms)

NullReferenceException: Object reference not set to an instance of an object
at ProductionManager.CheckProduction (System.Collections.Generic.List1 items) [0x00000] in <filename unknown>:0 at ProductionArrow.CheckLittleProduction () [0x00000] in <filename unknown>:0 at ItemSlot.OnEndDrag (UnityEngine.EventSystems.PointerEventData eventData) [0x00000] in <filename unknown>:0 at UnityEngine.EventSystems.ExecuteEvents.Execute (IEndDragHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in <filename unknown>:0 at UnityEngine.EventSystems.ExecuteEvents.Execute[IEndDragHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction1 functor) [0x00000] in :0
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
UnityEngine.EventSystems.StandaloneInputModule:processMousePress(MouseButtonEventData)
UnityEngine.EventSystems.StandaloneInputModule:processMouseEvent(Int32)
UnityEngine.EventSystems.StandaloneInputModule:processMouseEvent()
UnityEngine.EventSystems.StandaloneInputModule:process()
UnityEngine.EventSystems.EventSystem:Update()

(Filename: Line: -1)

Have you checked your code, specificly this class and method?

I tried to check with ui text in build, but it seemed there is no null object.

Or let me ask you a question, what should i understand from this part ??

This

NullReferenceException: Object reference not set to an instance of an object
at ProductionManager.CheckProduction (System.Collections.Generic.List1 items) [0x00000] in <filename unknown>:0 at ProductionArrow.CheckLittleProduction () [0x00000] in <filename unknown>:0 at ItemSlot.OnEndDrag (UnityEngine.EventSystems.PointerEventData eventData) [0x00000] in <filename unknown>:0 at UnityEngine.EventSystems.ExecuteEvents.Execute (IEndDragHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in <filename unknown>:0 at UnityEngine.EventSystems.ExecuteEvents.Execute[IEndDragHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction1 functor) [0x00000] in :0

and remember, it is only in build

ProductionManager.CheckProduction is throwing a NullReferenceException somewhere inside of it. It’s caused by the event system calling ItemSlot.OnEndDrag, which calls ProductionArrow.CheckLittleProduction, which calls ProductionManager.CheckProduction.

If you mark your build as a Debug build in the build menu, you should be getting the line number instead of :0

Thanks a lot for the information. I will check it. By the way, what might causes this error which is only in build ? Do you have idea ? Thanks again.

Finally, i got this. The problem was, my codes were trying to use undeclared array on OnValidate method. This should be about execution order. The debug build trick really worked so much. Thank so much for answers.

1 Like