Repo: "Object reference not set to an instance of an object"

Bug reports.
User avatar
Stub
Posts: 173
Joined: Fri Jul 15, 2016 1:35 pm

Repo: "Object reference not set to an instance of an object"

Post by Stub » Fri Jul 15, 2016 1:51 pm

I've just started learning how to use Ranorex and I made some changes to my Repository today that will no longer compile. It's reporting an error from within Ranorex and I'm unclear what has gone wrong. The following is what appears when I select Build on the solution.

It's reporting the "Error Details for file 'my .rxrep'.
Ranorex.RanorexException: Failed to update code. Object reference not set to an instance of an object.

An image of the stack trace dialog should be attached to this post. I'll poke around at the problem to see if I can figure out what has gone wrong. Any thoughts on what I might focus my attention on? I was just adding some new elements in a rooted/simpler folder structure and then bounced into a code module I'd written previously. So quite a few changes before I decided to build it.
Attachments
RanorexBuildProblem1.png
RanorexBuildProblem1.png (32.99 KiB) Viewed 1398 times

User avatar
Stub
Posts: 173
Joined: Fri Jul 15, 2016 1:35 pm

Re: Repo: "Object reference not set to an instance of an object"

Post by Stub » Mon Jul 18, 2016 7:52 am

NVM, folks, I deleted my repository objects in chunks until I found the failing item, then restored from source control. After I deleted the repository object everything went back to normal. Also just noticed the bug reporting forum too.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Repo: "Object reference not set to an instance of an object"

Post by krstcs » Mon Jul 18, 2016 2:57 pm

Were you editing the *.cs or *.rxrep file directly through another editor?

If so, you should not do this, except for merge conflicts, as Ranorex automatically generates these files when you make changes in the Ranorex Repository Editor.

If you did not change these files directly, then please let us know how this happened so the Ranorex team can figure out if it's a bug (and the rest of us can avoid it!! :D ).

Thanks!
Shortcuts usually aren't...

User avatar
Stub
Posts: 173
Joined: Fri Jul 15, 2016 1:35 pm

Re: Repo: "Object reference not set to an instance of an object"

Post by Stub » Tue Jul 19, 2016 8:36 am

No, I was just using the Ranorex Repository editor GUI to setup my items. Then it wouldn't compile when I was done and wanted to test something. So I simply reversed the process, deleting items from the Ranorex Repository editor GUI until it started to compile. Eventually I narrowed it down to one element, restored from source control, deleted just that item, again just using the Ranorex Repostitory editor GUI, and off I went as normal.

I commit regularly to source control, but I'd been making quite a few new GUI items in my repository at the time. Seems it's worth building within Ranorex regularly too.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Repo: "Object reference not set to an instance of an object"

Post by krstcs » Tue Jul 19, 2016 3:27 pm

Yeah, I recommend building before any commit to make sure your project compiles.

However, as I said, this may be a bug because if you are using the Ranorex Repository GUI, then there should not be a case where your code doesn't compile.

Would you be able to create a demo project that recreates this issue? It would help the Ranorex team debug the problem. If the SUT can't be release, would you be able to get a demo application that shows the problem? If so, please send it all to [email protected].


@Ranorex team: This sounds like a bug, could we move this to the bug forum, please?
Shortcuts usually aren't...

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Repo: "Object reference not set to an instance of an object"

Post by Support Team » Thu Jul 21, 2016 12:16 pm

Hello Stub,

May I ask which Ranorex version are you using? Do you see the issue after upgrading Ranorex? Which .NET Framework are you using in your project? Please select at least .NET 4.0 in the project properties.

As krstcs wrote, it would be easier for us to analyze the issue when having your project. Please write an e-mail to [email protected].

Regards,
Bernhard
.
Image

User avatar
jasoncleo
Posts: 37
Joined: Mon Jun 08, 2015 7:37 am

Re: Repo: "Object reference not set to an instance of an object"

Post by jasoncleo » Fri Nov 11, 2016 2:21 am

We just encountered this issue too. We're using Ranorex 6.1.0 on Win 7 x64.

In our scenario we have a UI Repository in one common project, and then other projects just include that so the user code modules can all leverage the one single UI repository.

The issue occurs when dragging Repository folders around to move them into other folders (e.g. moving repo folder X to become a child of repo folder Y). Even though the rxrep file shows the correct structure of where stuff has been moved, it seems to have some corrupted XML underneath for the modified, and it doesn't recover on its own.

The only way to recover is to either revert the change (either from the version control, or manually reversing the drag-and-drop), or delete the destination folder (i.e. delete repo folder Y).

So far, I've managed to escape any data loss by reversing drag and drops of folders. Compiling the UI repo (press F9) after each change helps me catch them as soon as they happen.

It doesn't happen all the time. So once I reverse the change, recompile successfully, then I can usually try again and have it work.

User avatar
Stub
Posts: 173
Joined: Fri Jul 15, 2016 1:35 pm

Re: Repo: "Object reference not set to an instance of an object"

Post by Stub » Fri Nov 11, 2016 9:27 am

jasoncleo,

I still hit this problem occasionally with Ranorex v6.1.1. I now commit to subversion on a regular basis as it goes wrong quite easily, though I've never tracked the exact scenario down to something manageable I can describe or submit.

So far it's most often struck when I simply rename a folder item, usually when it's of a more complicated/deep format. So before I do any kind of renaming or repository surgery I complete my work, save, commit to source control, try a single edit in the repository, then BUILD. As you've found this build step is critical to knowing when Ranorex has gone wrong and the repository is now messed up and the change must be reverted. Mostly I see this as build errors nowadays because of this new careful strategy.

Since it's gone wrong in the renaming, usually for me at least, I just rename it back again and all is well. But to complete the renaming I then create a new item and slowly drag drop all of the items out of the problem folder until the problematic folder is empty and I can finally safely delete it.

For the most part renaming repo items and having Ranorex update all the code works really well though! :D

csr
Posts: 9
Joined: Wed May 10, 2017 10:25 am

Re: Repo: "Object reference not set to an instance of an object"

Post by csr » Thu Feb 01, 2018 11:50 am

I cannot believe this issue still exists! I have just updated about 50 repository items in order to get our repository moved from the "WpfPreferred" plugin to the "WpfImproved" plugin (because we are having insane speed and reliability issues with the old plugin)!

Now I encountered the same error! I was using 7.2.1 and was hoping that maybe there is a fix in 8.0, but nope, no luck!

So what am I supposed to do now? Revert all the changes and start over? This is seriously unacceptable!

csr
Posts: 9
Joined: Wed May 10, 2017 10:25 am

Re: Repo: "Object reference not set to an instance of an object"

Post by csr » Thu Feb 01, 2018 12:02 pm

Why not just recreate the *.cs file (at least in case an update does not work)?
I have neither touched the *.rxrep, nor the *.rximg or the *.cs file, just used Ranorex Studio to update paths! I deleted some folders/objects and recreated folders/objects with the same name afterwards, I don't know if this is the cause of the problem (as the previous posters suggested), but even if so, just have an option to recreate the *.cs file from the *.rxrep file! The functionality must already be implemented! This makes Ranorex unusable!

csr
Posts: 9
Joined: Wed May 10, 2017 10:25 am

Re: Repo: "Object reference not set to an instance of an object"

Post by csr » Thu Feb 01, 2018 1:26 pm

So I just reproduced the problem.

Initial State:
- 5 buttons as children of a rooted folder (lets say "folder a", which itself is a child of other rooted folders)

Steps to reproduce error:
- Create a new rooted folder as child of "folder a"
- Move 5 buttons to "folder a" (acknowledge warning that base paths to not match)
- Try build -> build fails with "Failed to update code" error

When moving the buttons back into "folder a", the build error disappears.

csr
Posts: 9
Joined: Wed May 10, 2017 10:25 am

Re: Repo: "Object reference not set to an instance of an object"

Post by csr » Thu Feb 01, 2018 3:20 pm

Simply renaming an existing folder also leads to the error.

csr
Posts: 9
Joined: Wed May 10, 2017 10:25 am

Re: Repo: "Object reference not set to an instance of an object"

Post by csr » Thu Feb 01, 2018 5:39 pm

Another update: It apparently only occurs if the repository item is referenced somewhere in the code (e.g. in a user code module).

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Repo: "Object reference not set to an instance of an object"

Post by Support Team » Sat Feb 03, 2018 2:13 am

Hi csr,

Unfortunately, I was unable to duplicate your issue with the provided steps in a Ranorex 8.0 new solution. Is it possible to provide a sample solution which produces this error? With this, we can further investigate your issue and try to find the root cause. If you prefer, you can contact us to troubleshoot this via email.

I look forward to your response!

Cheers,
Ned
.
Image

csr
Posts: 9
Joined: Wed May 10, 2017 10:25 am

Re: Repo: "Object reference not set to an instance of an object"

Post by csr » Fri Feb 23, 2018 11:20 am

Hi,
I just had time to get back to our Ranorex Tests. So unfortunately, the issue does not seems to be easy to reproduce. In our production solution, I now have a scenario where the bug occurs, but I don't think it is possible to share the solution.

So what I am doing is:
  • I rename an existing Repo Item in Ranorex Studio. This item is once referenced in a Ranorex test class (implements ITestModule and has the TestModule attribute) and once in a a class that is no Ranorex module (ValidateImageProcessing.cs, which is no Code Module, User Code Collection, etc.)
  • I do a build in Ranorex Studio
  • -> The build fails with
    • Failed to update code for '...\xxx_TestautomationRepository.rxrep'. Failed to update code. Object reference not set to an instance of an object...
    • "xxx_TestautomationRepositoryFolders.BasicFolder" enthält keine Definition für "ToggleButtonZoom1xInfo" (this is the renamed name), und es konnte keine ToggleButtonZoom1xInfo-Erweiterungsmethode gefunden werden, die ein erstes Argument vom Typ "xxx_TestautomationRepositoryFolders.BasicFolder" akzeptiert (möglicherweise fehlt eine using-Direktive oder ein Assemblyverweis). (CS1061) - ...\Validation\ValidateImageProcessing.cs:18,82
So this non-Ranorex class (ValidateImageProcessing.cs) where the Repo item is referenced is also in a separate project in the solution. Maybe this is the cause of the problem, because Ranorex sucessfully changes the Name of the referenced repo item in this class, but not in the other one and neither in the generated repository .cs file.

I hope this information helps, because it is really horrible to work like this! Every time I change something, I have to do a build in order to be sure that nothing went wrong!

If you cannot reproduce the error, please at least give an option to disable this feature which tries to automatically rename the repo items in code!! Or catch this exception and still go on with generating the repo .cs file instead of just aborting everything! Please, please, please!