Invoke Code, LogMessage bug

Hi,

We recently updated to 2018.4.3, and I noticed that for logging in invoke code activity, LogMessage.Message input argument changed from string to object.

Dim logMessage As UiPath.Core.Activities.LogMessage 
Dim logInvoker As WorkflowInvoker 

logMessage =  New UiPath.Core.Activities.LogMessage()
 logMessage.Level = UiPath.Core.Activities.CurentLogLevel.Info
 logMessage.Message = "test message"
 logInvoker.invoke (logMessage) 
 logMessage = Nothing

logMessage.Message = "test message" does not accept string, and I’m having trouble converting this string into System.Activities.InArgument (Of Object) - it seems that this is the type it accepts. Therefore I’m unable currently to log from Invoke Code activity

Can anyone give me a suggestion how to do this?

Thank you

Edit: corrected type of input from Object to System.Activities.InArgument (Of Object)

3 Likes

Hi @Mkoval,

You can use CType conversions to convert the data types to any other type.

To convert string to the object, here is the code :

         Dim rangeString As String
        Dim obj As Object = CType(rangeString, Object)

Hope it helps

Nope, in your example you are converting string into string and trying to assign it to object.
I made wrong assumption in the beginning. LogMessage.Message, accepts System.Activities.InArgument (Of Object) as input

So how to get there

You are going to give yourself a real headache if you try to do this in code instead of through Studio, as I assume you are doing right now based on your sample in the OP.

But if you want to - check below link, you might want to try passing a named dictionary alongside the activity:

There are other ways, but I gave up on this route some time ago.

Do note that no guarantees are given if you develop outside of Studio and reference UiPath packages (so above breaking change, while true, is NOT a bug, but an intended change since in Studio it is not a breaking change).

Hello @Mkoval,
I have met the same problem since updated to 2018.4.4, too
Because there are so many logMessage codes in different InvokeCode activities I used, it’s hard to fix it one by one…
Do you have any idea about this problem or have any suggestion ?

No, I spent maybe 3 days trying different approaches. In the end I pulled the logging out of VB, and broke VB into multiple separate parts. It was little bit of headache, as my code worked with COM objects. To sum it up, I had to completely rewrite the code, and we are deploying it this weekend together with production Orchestrator update

I found that the description of logMessage.Message was System.Activities.InArgument (Of String) in 2.6, but now it is System.Activities.InArgument (Of Object), maybe it’s a bugfix (or a new bug :joy:)?
Anyway, thanks for your reply!

1 Like