Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Hi @WCrihfield 

 

Main Rule

AddReference "System.Data"
AddReference "System.Xml"
AddReference "Microsoft.Office.Interop.Excel.dll"
AddVbFile "...\mLog.vb"
AddVbFile "...\cMagnum.vb"

Class ThisRule
   '...
   Private oMagnum As cMagnum
   '...
   Sub Main

      StartLog
      oMagnum = New cMagnum(Logger, arrayRiga, transcodifica)
      '...
      '...

   End Sub
End Class

 

mLog.vb

Imports Autodesk.iLogic.Core
Imports Autodesk.iLogic.Interfaces
Imports Autodesk.Inventor
Imports System

Public Module mLog

    Private iLogicAuto As Autodesk.iLogic.Interfaces.IiLogicAutomation
    Private Logger As Autodesk.iLogic.Interfaces.IRuleLogger
    'Public logCtrl As LogControl
    'Public Log As IRuleLogger

    Public Sub StartLog()'(startMarker As String)
		Logger.Debug("TEST MODULO")
        'Log.Debug(startMarker)
		'Log.Trace("**Class cLog - StartLog")
        'Log.Info(" Log regola lanciata alle " & DateTime.Now)
    End Sub

    Public Sub EndLog(startMarker As String, nomeRegola As String, Optional percorsoLogCompleto As String = "...\Log", _
                            Optional percorsoLogPuntuale As String = "...\Log", Optional fullLog As Boolean = True, _
                            Optional puntualLog As Boolean = True)
       '...
       '...
       logCtrl.SaveLogAs(tempfile)
       '...
       '...
   End Sub
End Module

 

cMagnum.vb

Imports System.IO
Imports System.Data
Imports System.Xml

Public Class cMagnum
   Dim Log As IRuleLogger
   '...
   '...

	Public Sub New(log As IRuleLogger, datiConfigurazione(,) As Object,configPath As String )
		Me.Log = log
                '...
                '...
	End Sub

    '...
    '...

	Private ReadOnly Property calcolo_LT As Integer
		Get
			value = L - 2 * AMT
			Log.Trace("Valore di LT: " & value)
			Return value
		End Get
	End Property

    '...
    '...

End Class

 

The logger works perfectly on the class cMagnum, but not in the module mLog.

I get the error: "Object reference not set to an object instance."

 

This is only an example but the main concepet is that i need to create some "module" that can be recalled inside other classes as isn't possible to call a class inside another class as far as i know, and obviously i need to use the logger inside them.

 

I hope I have been as clear as possible.