Customization Error - Object reference not set to an instance of

 #ygrps-yiv-1986106303 .ygrps-yiv-1986106303ygrp-photo-title { TEXT-ALIGN:center;WIDTH:75px;HEIGHT:15px;CLEAR:both;FONT-SIZE:smaller;OVERFLOW:hidden;} #ygrps-yiv-1986106303 DIV.ygrps-yiv-1986106303ygrp-photo { BORDER-BOTTOM:black 1px solid;BORDER-LEFT:black 1px solid;BACKGROUND-COLOR:white;WIDTH:62px;BACKGROUND-REPEAT:no-repeat;BACKGROUND-POSITION:center 50%;HEIGHT:62px;BORDER-TOP:black 1px solid;BORDER-RIGHT:black 1px solid;} #ygrps-yiv-1986106303 DIV.ygrps-yiv-1986106303photo-title A { TEXT-DECORATION:none;} #ygrps-yiv-1986106303 DIV.ygrps-yiv-1986106303photo-title A:active { TEXT-DECORATION:none;} #ygrps-yiv-1986106303 DIV.ygrps-yiv-1986106303photo-title A:hover { TEXT-DECORATION:none;} #ygrps-yiv-1986106303 DIV.ygrps-yiv-1986106303photo-title A:visited { TEXT-DECORATION:none;} #ygrps-yiv-1986106303 DIV.ygrps-yiv-1986106303attach-table DIV.ygrps-yiv-1986106303attach-row { CLEAR:both;} #ygrps-yiv-1986106303 DIV.ygrps-yiv-1986106303attach-table DIV.ygrps-yiv-1986106303attach-row DIV { FLOAT:left;} #ygrps-yiv-1986106303 P { PADDING-BOTTOM:3px;PADDING-LEFT:0px;PADDING-RIGHT:0px;CLEAR:both;OVERFLOW:hidden;PADDING-TOP:15px;} #ygrps-yiv-1986106303 DIV.ygrps-yiv-1986106303ygrp-file { WIDTH:30px;} #ygrps-yiv-1986106303 DIV.ygrps-yiv-1986106303attach-table DIV.ygrps-yiv-1986106303attach-row DIV DIV A { TEXT-DECORATION:none;} #ygrps-yiv-1986106303 DIV.ygrps-yiv-1986106303attach-table DIV.ygrps-yiv-1986106303attach-row DIV DIV SPAN { FONT-WEIGHT:normal;} #ygrps-yiv-1986106303 DIV.ygrps-yiv-1986106303ygrp-file-title { FONT-WEIGHT:bold;}
The Personalization files exist on the Epicor Server and are downloaded to the Client for performance. Whether the client is on a PC or Citrix Server is immaterial. So if a user is on Citrix1 and makes a personalization change, its updated on the Server as well as Citrix1. When they login to Citrix2, perhaps the next day or week, the Citrix2 file is refreshed from the Server as its outdated. The main thing to set correctly is the permissions on the Epicor folder on all clients. This means the Modify as well as Write Access for all users.
 
But I wouldn't delete all of them on a Citrix Server unless no one is logged in, perhaps on the weekend. And everyone will be a bit slower the next time they login as the files will have to be recopied from the Server.
 
If you're still queezy, try it out on the Pilot/Test Folders under Epicor first.
 
----- Original Message -----
Sent: Friday, May 30, 2014 12:02 PM
Subject: [Vantage] Re: Customization Error - Object reference not set to an instance of an object

I will look through the customization code again sometime next week to make sure I'm disposing of all my objects properly.

I don't feel comfortable running that batch file because we are running in a Citrix environment.  Everyone's Epicor folders are located on two terminal servers.  If something went wrong, it wouldn't just affect that single person.  But thank you for the idea.  I can take the "cache" idea into consideration when troubleshooting this further.  :)

I have customizations set up in Job Tracker and Job Entry (Vantage 8.03.410).  A few months back, I added functionality to change the operation and material nodes in the method tree to red if it is an added op or an added material. 


Not long ago, an end user told me errors pop up when trying to launch either of these screens.  They click ok and can continue but the red functionality no longer works for that session.  They said the errors have been happening for a really long time (they just didn't tell me until now) so I'm not sure if the method tree functionality is what causes the error or if it is something else in the customization.


The odd thing is, it works sometimes.  This may be a coincidence but when it starts giving errors, I go in and recompile the two relevant customizations and the errors go away for a while.


Below is the error message along with my code for the Job Tracker customization. 


Does anyone have any ideas of what is causing this??




Error Detail


============


Exception has been thrown by
the target of an invocation.


 


 


Stack Trace


===========


   at
System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments,
SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle
typeOwner)


   at
System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments,
Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)


   at
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr,
Binder binder, Object[] parameters, CultureInfo culture, Boolean
skipVisibilityChecks)


   at
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr,
Binder binder, Object[] parameters, CultureInfo culture)


   at
Epicor.Mfg.UI.Customization.CustomScriptManager.initCustomAssembly(Assembly
assm)


 


Inner Exception


===============


Object reference not set to an
instance of an object.


 


Inner Stack Trace


=================











'//
'// Custom VB.NET code for JobTrackerForm
'// Created: 12/29/2007 3:13:47 PM
'//

Imports System
Imports System.Data
Imports System.Diagnostics
Imports System.Windows.Forms
Imports System.ComponentModel
Imports Microsoft.VisualBasic
Imports Epicor.Mfg.UI
Imports Epicor.Mfg.UI.FrameWork
Imports Epicor.Mfg.UI.ExtendedProps
Imports Epicor.Mfg.UI.FormFunctions
Imports Epicor.Mfg.UI.Customization
Imports Epicor.Mfg.UI.Adapters
Imports Epicor.Mfg.UI.Searches
Imports Epicor.Mfg.BO
Imports System.Reflection


Module Script



    '// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
    '// Begin Wizard Added Module Level Variables **
    Private WithEvents oTrans_adapter As EpiBaseAdapter
    Private WithEvents edvJobHead As EpiDataView
    Private WithEvents edvCustJobHeadPartRevTrack As EpiDataView   
    '// End Wizard Added Module Level Variables **
   
    '// Add Custom Module Level Variables Here **
    Dim jobNum as String
    Dim assemblOpSeq as Integer
    Dim assemblMtlSeq as Integer
     
    Dim jobOper As JobOperSearch
    Dim jobOpDS As JobOperListDataSet
    Dim addedOps(0) As Integer  
   
    Dim jobMtl As JobMtlSearch
    Dim jobMtlDS As JobMtlListDataSet
    Dim addedMtls(0) As Integer
   
    Private WithEvents theJobTree As Epicor.Mfg.UI.FrameWork.JobLib.MethodTree   
    Dim fi As FieldInfo
    Dim tvp As Epicor.Mfg.UI.FrameWork.JobLib.MethodTreePanel

    Sub InitializeCustomCode()
        '// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Intialization' lines **
        '// Begin Wizard Added Variable Intialization

        oTrans_adapter = csm.TransAdaptersHT("oTrans_adapter")
        edvJobHead = CType(oTrans.EpiDataViews("JobHead"), EpiDataView)
        edvCustJobHeadPartRevTrack = CType(oTrans.EpiDataViews("CustJobHeadPartRevTrack"), EpiDataView)
        '// End Wizard Added Variable Intialization
              
        jobNum = ""
        assemblOpSeq = -1
        assemblMtlSeq = -1
     
        jobOper = New JobOperSearch(oTrans.Session.ConnectionPool)
        jobOpDS = Nothing
        Array.Clear(addedOps, 0, addedOps.Length)
       
        jobMtl = New JobMtlSearch(oTrans.Session.ConnectionPool)
        jobMtlDS = Nothing
        Array.Clear(addedMtls, 0, addedMtls.Length)
       
        'fi = GetType(Epicor.Mfg.UI.App.JobTracker.JobTrackerForm).GetField("jobTreeViewPanel",BindingFlags.NonPublic Or BindingFlags.GetField Or BindingFlags.Instance)
        'tvp = fi.GetValue(JobTrackerForm)
        'theJobTree = tvp.MethodTree
       
        '// Begin Custom Method Calls
        AddAppearancesToECNTextBox()
        '// End Custom Method Calls
    End Sub

    Sub DestroyCustomCode()
        '// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
        '// Begin Wizard Added Object Disposal
        oTrans_adapter = Nothing
        edvJobHead = Nothing
        edvCustJobHeadPartRevTrack = Nothing
        '// End Wizard Added Object Disposal
       
        '// Begin Custom Code Disposal
        jobNum = Nothing
        assemblOpSeq = Nothing
        assemblMtlSeq = Nothing

        jobOper = Nothing
        jobOpDS = Nothing
        addedOps = Nothing
       
        jobMtl = Nothing
        jobMtlDS = Nothing
        addedMtls = Nothing
       
        If theJobTree Is Nothing = False Then
            theJobTree = Nothing
        End If  
        If fi Is Nothing = False Then
            fi = Nothing
        End If
        If tvp Is Nothing = False Then
            tvp = Nothing       
        End If
        '// End Custom Code Disposal
    End Sub

    Private Sub JobTrackerForm_Load(ByVal sender As object, ByVal args As EventArgs) Handles JobTrackerForm.Load
        Try
            fi = GetType(Epicor.Mfg.UI.App.JobTracker.JobTrackerForm).GetField("jobTreeViewPanel",BindingFlags.NonPublic Or BindingFlags.GetField Or BindingFlags.Instance)
            tvp = fi.GetValue(JobTrackerForm)
            theJobTree = tvp.MethodTree       
        Catch
       
        End Try
 End Sub
   
    Private Sub AfterExpandTheJobTree(ByVal sender as Object, ByVal args As Infragistics.Win.UltraWinTree.NodeEventArgs) Handles theJobTree.AfterExpand
        'edvJobHead = CType(oTrans.EpiDataViews("JobHead"), EpiDataView)
        'If args.TreeNode.Text = "Operations" Or args.TreeNode.Text = "Materials" Then
        If theJobTree Is Nothing = False Then
            ColorTree(args.TreeNode)
        End If
        'End If
    End Sub
   
    Private Sub ColorTree(ByVal n as EpiTreeNode)
        Try
            jobNum = ""
            assemblOpSeq = -1
            assemblMtlSeq = -1
         
            'jobOper = New JobOperSearch(oTrans.Session.ConnectionPool)
            jobOpDS = Nothing
            Array.Clear(addedOps, 0, addedOps.Length)
           
            'jobMtl = New JobMtlSearch(oTrans.Session.ConnectionPool)
            jobMtlDS = Nothing
            Array.Clear(addedMtls, 0, addedMtls.Length)
           
            'Dim fi As FieldInfo = GetType(Epicor.Mfg.UI.App.JobEntry.JobEntryForm).GetField("jobTreeViewPanel",BindingFlags.NonPublic Or BindingFlags.GetField Or BindingFlags.Instance)
            'Dim tvp As Epicor.Mfg.UI.FrameWork.JobLib.MethodTreePanel = fi.GetValue(JobEntryForm)
            'theJobTree = tvp.MethodTree   
       
            PrintRecursive(n)
        Catch
       
        End Try
       
    End Sub
   
    Private Sub PrintRecursive(ByVal n as EpiTreeNode) 
        Try  
            Dim nodeOpNum As Integer = Nothing
            Dim nodeMtlNum As Integer = Nothing
           
            For Each aNode As EpiTreeNode In n.Nodes
                aNode.Override.NodeAppearance.ForeColor = System.Drawing.Color.Black
                If aNode.Text.StartsWith("Opr:") Then           
                    Dim strArray As String() = Split(aNode.Text, Chr(32))                                  
                    nodeOpNum = CInt(strArray(1))
                    Array.Clear(strArray, 0, strArray.Length)
                   
                    If Not(nodeOpNum = Nothing) Then
                        strArray = Split(aNode.Parent.Parent.Text,Chr(32)) 
                        If assemblOpSeq <> CInt(strArray(1)) Then
                            assemblOpSeq = CInt(strArray(1))
                            Array.Clear(addedOps, 0, addedOps.Length)                                            
                            jobOpDS = jobOper.GetList("JobNum = '" + edvJobHead.dataView(0)("JobNum") + "' AND AssemblySeq = " + CStr(assemblOpSeq), 0, 0, False)
                            Dim nextIndex as Integer = 0
                            For each r as JobOperListDataSet.JobOperListRow In jobOpDS.JobOperList.Rows
                                If r.AddedOper = True Then                                                          
                                    ReDim Preserve addedOps(nextIndex)
                                    addedOps(nextIndex) = r.OprSeq
                                    nextIndex = addedOps.GetUpperBound(0) + 1
                                End If
                            Next
                        End If
                   
                        If Not(addedOps Is Nothing) And addedOps.Length > 0 Then
                            If Array.IndexOf(addedOps,nodeOpNum) > -1 Then
                                aNode.Override.NodeAppearance.ForeColor = System.Drawing.Color.Red
                            End If                   
                        End If
                    End If           
                Else If aNode.Text.StartsWith("Mtl:") Then                    
                    Dim strArray As String() = Split(aNode.Text, Chr(32))                                  
                    nodeMtlNum = CInt(strArray(1))
                    Array.Clear(strArray, 0, strArray.Length)
                   
                    If Not(nodeMtlNum = Nothing) Then
                        If aNode.Parent.Parent.Text <> "Operations" Then
                            strArray = Split(aNode.Parent.Parent.Text,Chr(32))
                        Else
                            strArray = Split(aNode.Parent.Parent.Parent.Text,Chr(32))
                        End If
                       
                        If assemblMtlSeq <> CInt(strArray(1)) Then
                            assemblMtlSeq = CInt(strArray(1))
                            Array.Clear(addedMtls, 0, addedMtls.Length)                                            
                            jobMtlDS = jobMtl.GetList("JobNum = '" + edvJobHead.dataView(0)("JobNum") + "' AND AssemblySeq = " + CStr(assemblMtlSeq), 0, 0, False)
                            Dim nextIndex as Integer = 0
                            For each r as JobMtlListDataSet.JobMtlListRow In jobMtlDS.JobMtlList.Rows
                                If r.AddedMtl = True Then                                                          
                                    ReDim Preserve addedMtls(nextIndex)
                                    addedMtls(nextIndex) = r.MtlSeq
                                    nextIndex = addedMtls.GetUpperBound(0) + 1
                                End If
                            Next
                        End If
                   
                        If Not(addedMtls Is Nothing) And addedMtls.Length > 0 Then
                            If Array.IndexOf(addedMtls,nodeMtlNum) > -1 Then
                                aNode.Override.NodeAppearance.ForeColor = System.Drawing.Color.Red
                            End If                   
                        End If
                    End If                              
                   
                End If
                PrintRecursive(aNode)
            Next
        Catch
        End Try
    End Sub
     
    Private Sub edvCustJobHeadPartRevTrack_EpiViewNotification(view As EpiDataView, args As EpiNotifyArgs) Handles edvCustJobHeadPartRevTrack.EpiViewNotification
        '// ** Argument Properties and Uses **
        '// view.dataView(args.Row)("[FieldName]")
        '// args.Row, args.Column, args.Sender, args.NotifyType
        '// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
       
        'If (args.NotifyType = EpiTransaction.NotifyType.AddRow) Then
        If (args.Row > -1) Then
            SetECNTextBackColor()
        End If
        'End If
    End Sub
   
    Private Sub AddAppearancesToECNTextBox()
        Try
            txtEpiCustom2.Appearances.Clear
   
            Dim yellowAppearance As New Infragistics.Win.Appearance
            yellowAppearance.BackColor = Drawing.Color.Yellow
            yellowAppearance.Key = "ECNInProcess"
   
            Dim blueAppearance As New Infragistics.Win.Appearance
            blueAppearance.BackColor = Drawing.Color.SkyBlue
            blueAppearance.Key = "ECNNotInProcessHasECNText"
   
            Dim noAppearance As New Infragistics.Win.Appearance
            noAppearance.BackColor = Drawing.Color.Empty
            noAppearance.Key = "NoBackColor"
    
            txtEpiCustom2.Appearances.Add(yellowAppearance)
            txtEpiCustom2.Appearances.Add(blueAppearance)
            txtEpiCustom2.Appearances.Add(noAppearance)
        Catch
       
        End Try
       
    End Sub
   
    Private Sub SetECNTextBackColor()
        Try
            txtEpiCustom2.Appearance = txtEpiCustom2.Appearances("NoBackColor")
       
            If edvCustJobHeadPartRevTrack.dataView.Count > 0 Then
                If edvCustJobHeadPartRevTrack.dataView(edvCustJobHeadPartRevTrack.Row)("CheckBox03") = True Then
                    txtEpiCustom2.Appearance = txtEpiCustom2.Appearances("ECNInProcess")
                Else If TRIM(edvCustJobHeadPartRevTrack.dataView(edvCustJobHeadPartRevTrack.Row)("Character03")) <> ""
                    txtEpiCustom2.Appearance = txtEpiCustom2.Appearances("ECNNotInProcessHasECNText")
                End If                     
            End If
   
            txtEpiCustom2.Refresh()
        Catch
       
        End Try                
    End Sub

End Module

Do you remember if you deleted any custom fields from one of the tabs?

This is where I find the error comes from with mine.


Did you try "Test Code" under Tools or F5 in the customization that might help.

The "test code" completes successfully.  The customization even runs okay for a while.  When the users start getting the error message when launching Job Entry or Job Tracker, I go into the customization and "test code" again (to recompile it) and it works again.
Anyone have any ideas what this could be?

does the detail of the error give you any clues? are there any fields that are either greyed out or have a red X on them once the screen loads?

 

sometimes you can load in customization mode and make one small change and compile and that will fix.

 

You can also use customization maintenance and run verify. Hopefully this will point out the error and then you can delete the problem.

 

The next level would be to show custom data and remove by hand.  Be sure to export or make a copy first because you can wreck things quickly here.

 

From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com]
Sent: Friday, May 30, 2014 8:53 AM
To: vantage@yahoogroups.com
Subject: [Vantage] Re: Customization Error - Object reference not set to an instance of an object

 

 

Anyone have any ideas what this could be?



CONFIDENTIALITY NOTICE

The information contained in this communication, including attachments, is privileged and confidential. It is intended only for the exclusive use of the addressee. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us at 727-578-6280 and immediately delete the communication.

"This (document/presentation) may contain technical data as defined in the International Traffic In Arms Regulations (ITAR) 22 CFR 120.10. Export of this material is restricted by the Arms Export Control Act (22 U.S.C. 2751 et seq.) and may not be exported to foreign persons without prior approval form the U.S. Department of State."

No.  The error is quite generic (I posted it in my initial request).  No fields are greyed out or have an X on them.  The verify also runs fine.


The thing I'm confused about is everything builds fine and it is in use in our live system.  Eventually, those two screens start having issues down the road (without any modifications to either of those customizations).


If there were no changes on the customization end from the time it works to the time it starts having errors, what would the cause be?


(Note: A month or so back, I even rebuilt the customization from scratch to eliminate any custom data that wasn't suppose to be there.)

 

It could be a conflict with another module or old cached info. I have a batch file (below) that cleans out all of Epicor’s cached info to clear up odd issues. Only run while Epicor is closed.

 

Is it possible that an object didn’t get disposed in this or another customization that has the same name?

 

rem Windows 7

rd /S /Q c:\ProgramData\Epicor

 

 

rem Windows XP

rd /S /Q "c:\Documents and Settings\All Users\Application Data\Epicor"

 

From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com]
Sent: Friday, May 30, 2014 11:16 AM
To: vantage@yahoogroups.com
Subject: [Vantage] Re: Customization Error - Object reference not set to an instance of an object

 

 

No.  The error is quite generic (I posted it in my initial request).  No fields are greyed out or have an X on them.  The verify also runs fine.

 

The thing I'm confused about is everything builds fine and it is in use in our live system.  Eventually, those two screens start having issues down the road (without any modifications to either of those customizations).

 

If there were no changes on the customization end from the time it works to the time it starts having errors, what would the cause be?

 

(Note: A month or so back, I even rebuilt the customization from scratch to eliminate any custom data that wasn't suppose to be there.)



CONFIDENTIALITY NOTICE

The information contained in this communication, including attachments, is privileged and confidential. It is intended only for the exclusive use of the addressee. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us at 727-578-6280 and immediately delete the communication.

"This (document/presentation) may contain technical data as defined in the International Traffic In Arms Regulations (ITAR) 22 CFR 120.10. Export of this material is restricted by the Arms Export Control Act (22 U.S.C. 2751 et seq.) and may not be exported to foreign persons without prior approval form the U.S. Department of State."

I will look through the customization code again sometime next week to make sure I'm disposing of all my objects properly.


I don't feel comfortable running that batch file because we are running in a Citrix environment.  Everyone's Epicor folders are located on two terminal servers.  If something went wrong, it wouldn't just affect that single person.  But thank you for the idea.  I can take the "cache" idea into consideration when troubleshooting this further.  :)