# Object Reference error in invoke code workflowinvoker.invoke method

**URL:** <https://forum.uipath.com/t/object-reference-error-in-invoke-code-workflowinvoker-invoke-method/735765>\
**Category:** Activities\
**Tags:** activities-panel, studio, system, activities\
**Created:** [April 19, 2024, 3:35pm UTC](https://forum.uipath.com/t/object-reference-error-in-invoke-code-workflowinvoker-invoke-method/735765 "2024-04-19T15:35:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nirav\_Gajera](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nirav_gajera/32/319606_2.png) [@Nirav\_Gajera](https://forum.uipath.com/u/Nirav_Gajera)\
**Post date:** [April 19, 2024, 3:35pm UTC](https://forum.uipath.com/t/object-reference-error-in-invoke-code-workflowinvoker-invoke-method/735765/1 "2024-04-19T15:35:41Z")

</div>

I am trying to invoke log message activity in invoke code but getting object reference error at workflowinvoker.invoke method  
Code inside invoke code:  
Dim logMessage As UiPath.Core.Activities.LogMessage = New UiPath.Core.Activities.LogMessage()  
logMessage.Level = New InArgument(Of LogLevel)(LogLevel.Error)  
logMessage.Message = New InArgument(Of Object)(“abcd”)  
Dim logInvoker As System.Activities.WorkflowInvoker = New System.Activities.WorkflowInvoker(logMessage)  
logInvoker.Invoke()

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [April 19, 2024, 5:02pm UTC](https://forum.uipath.com/t/object-reference-error-in-invoke-code-workflowinvoker-invoke-method/735765/2 "2024-04-19T17:02:02Z")

</div>

@Nirav_Gajera

Try changing lomessage variable to something else

Cheers

---

<div class="post-metadata">

**Author:** ![postwick](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/postwick/32/227083_2.png) [@postwick](https://forum.uipath.com/u/postwick)\
**Post date:** [April 19, 2024, 5:02pm UTC](https://forum.uipath.com/t/object-reference-error-in-invoke-code-workflowinvoker-invoke-method/735765/3 "2024-04-19T17:02:26Z")

</div>

Object Reference not set to an instance of an object means the variable is not initialized (it’s null). This means your calling workflow does not have a value for that argument.

---

<div class="post-metadata">

**Author:** ![Nirav\_Gajera](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nirav_gajera/32/319606_2.png) [@Nirav\_Gajera](https://forum.uipath.com/u/Nirav_Gajera)\
**Post date:** [April 19, 2024, 6:11pm UTC](https://forum.uipath.com/t/object-reference-error-in-invoke-code-workflowinvoker-invoke-method/735765/4 "2024-04-19T18:11:45Z")

</div>

The same code is working fine inside the library but when I tried to use the same in the new project, it is throwing object reference error at invoke method. System.activities package is also same and imports are also matching so I am wandering what could be the issue here

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [April 19, 2024, 6:14pm UTC](https://forum.uipath.com/t/object-reference-error-in-invoke-code-workflowinvoker-invoke-method/735765/5 "2024-04-19T18:14:15Z")

</div>

@Nirav_Gajera

So are you trying to use that created log mesage method in the workflow?

If so it might not work as they are two different instances also

Cheers

---

<div class="post-metadata">

**Author:** ![Nirav\_Gajera](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nirav_gajera/32/319606_2.png) [@Nirav\_Gajera](https://forum.uipath.com/u/Nirav_Gajera)\
**Post date:** [April 19, 2024, 6:20pm UTC](https://forum.uipath.com/t/object-reference-error-in-invoke-code-workflowinvoker-invoke-method/735765/6 "2024-04-19T18:20:31Z")

</div>

No, I am using same pice of code but it works inside the library which is not connected to any of the project. Now I have to use it in entirely new project, so I did the same by dragging invoke code activity and writting same lines but it is not working in this new project. I am quite aware what object reference is and here object is initialised but somehow object reference error at invoke method.

---

<div class="post-metadata">

**Author:** ![Nirav\_Gajera](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nirav_gajera/32/319606_2.png) [@Nirav\_Gajera](https://forum.uipath.com/u/Nirav_Gajera)\
**Post date:** [April 19, 2024, 6:24pm UTC](https://forum.uipath.com/t/object-reference-error-in-invoke-code-workflowinvoker-invoke-method/735765/7 "2024-04-19T18:24:13Z")

</div>

Log message object is initialised and has all the arguments set up correctly, I am not sure why object reference error at invoke method. Also it is working fine in other independent Library so I am just wandering if it is import issue or something like that but not sure as imports are also matching and package is also matching with that library.

---

<div class="post-metadata">

**Author:** ![postwick](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/postwick/32/227083_2.png) [@postwick](https://forum.uipath.com/u/postwick)\
**Post date:** [April 19, 2024, 6:24pm UTC](https://forum.uipath.com/t/object-reference-error-in-invoke-code-workflowinvoker-invoke-method/735765/8 "2024-04-19T18:24:21Z")

</div>

Check and see if you accidentally have a variable with the same name as the argument. I’ve done this and pulled my hair out for a while trying to find the problem.

Another problem may be that you have the default of a variable/argument that includes another variable/argument. For example:

 ![image](https://global.discourse-cdn.com/uipath/original/4X/1/2/4/1243eb5e4a1a400a4227da53ff01efd540670691.png)

That will cause an Object Reference error.

---

<div class="post-metadata">

**Author:** ![Nirav\_Gajera](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nirav_gajera/32/319606_2.png) [@Nirav\_Gajera](https://forum.uipath.com/u/Nirav_Gajera)\
**Post date:** [May 13, 2024, 10:43am UTC](https://forum.uipath.com/t/object-reference-error-in-invoke-code-workflowinvoker-invoke-method/735765/9 "2024-05-13T10:43:54Z")

</div>

It is also not the case, I am sharing the code block that I am using inside Invoke code. Any suggestion is appreciated.

```auto
	Try 
		Dim logMessage1 As UiPath.Core.Activities.LogMessage = New UiPath.Core.Activities.LogMessage()
		logMessage1.Level = New InArgument(Of LogLevel)(LogLevel.Error)
		logMessage1.Message = New InArgument(Of Object)("ABC")
		Dim logInvoker As WorkflowInvoker = New WorkflowInvoker(logMessage1)
		logInvoker.Invoke()
	Catch e As Exception
		Console.WriteLine(e.Message)
	End Try

```

---

<div class="post-metadata">

**Author:** ![Laszlo\_Kajan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/laszlo_kajan/32/483862_2.png) [@Laszlo\_Kajan](https://forum.uipath.com/u/Laszlo_Kajan)\
**Post date:** [July 12, 2024, 12:40pm UTC](https://forum.uipath.com/t/object-reference-error-in-invoke-code-workflowinvoker-invoke-method/735765/10 "2024-07-12T12:40:47Z")

</div>

+1 - same problem here, Studio 2024.10.1, UiPath.System.Activities v24.10.3
