System.NullReferenceException: Object reference not set to an instance of an object

When I’m trying to Get a website path variable from the config file, I’m getting the error.

The error pops up when I try to assign the variable with the config key in the variable management section.

It’s works fine if I use an assign activity to do this,but while setting the default value to the variable this issue arises.

I’ve set the scope of the variable to General Business and used Config(“WebsitePath”).ToString to assign.

What is the issue here?

1 Like

@DanRagh

Welcome to forums

Can you check the config argument is passing correctly?

As the argument is not passing correctly it is having the null value which throws you the error

Also, check that the config file has the WebsitePath Key and no spaces etc.,

Thanks

@DanRagh

Welcome to our UiPath community.

You need to define WebsitePath as Name and corresponding value as Key in Config and then read it as like below.

      Config("WebsitePath").ToString

Hey,

Yes the argument is passing correctly, as the flow is working properly when im using the assign activity just above the workflow. And there’s no spaces in the config file.

@lakshman

Hi, I have done that in the settings sheet of the config file.

Still the error persist.

Hello @DanRagh

As per your comment above, can you please let us know whether you are facing issue only while assigning a default value ? If so, you will not able to do this as UiPath will not be able to find the value while initialising !

Please try to use within Assign activity and you shall get default value assigned to some other variables.

Thanks

Hi,

You cannot provide config path in the Default of the varaible in the initial stage itself it will throw object refrerence not set to an instance of object error since it cannot pass the value from the config file. instead of that you have to use assign as you already tried and one more method is you can use invoke work flow activity for opening any application there you can pass this WebsitePath value as argument.

Regards,
Kirankumar.

@DanRagh

Can you print the below value using Message Box activity before that Assign activity and check whether it is printing proper value or not.

         Config(“WebsitePath”).ToString

Hey, @jeshwanthaloy

Thank You.Will make a note of that from now on.

Hey @kirankumar.mahanthi1

Thank you, Will make a note of that .

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.