0 votes
by (320 points)

Code that triggers the exception:

        private void CreateFiles(
        List<DeviceUsageRecord> statistics,
        string tenant,
        DirectoryNode organisationFolder)
        foreach (FileNode file in organisationFolder.GetFiles())
            if (!file.IsDeleted)

        IEnumerable<IGrouping<string, DeviceUsageRecord>> statisticsGroupedByTenant = statistics
            .OrderBy(x => (x.ReceivedAt.Date, x.TherapyDate.Date))
            .GroupBy(x => x.DeviceBinding.Tenant);

        foreach (IGrouping<string, DeviceUsageRecord> organisationStatistics in
            IEnumerable<IGrouping<DateTime, DeviceUsageRecord>>
                statisticsGroupedByTransmissionDate =
                    organisationStatistics.GroupBy(x => x.ReceivedAt.Date);

            foreach (IGrouping<DateTime, DeviceUsageRecord> usageRow in
                var userFile = new FileNode(

                // ^ I assume NRE happens here ^

                string fileData = usageRow.ToCsv(


enter image description here

My assumption is that something is wrong with DirectoryNode that is passed inside FileNode, but DirectoryNode for sure is not null, because this way we would get NRE in the beginning of this method, and constructor of FileNode is protected against null arguments as well.

by (5.1k points)
edited by
1) What kind of file system provider do you use? LocalFileSystemProvider,  other?
2) Did you try the latest version of our components? https://www.rebex.net/total-pack/download.aspx
3) Could you please share a compilable minimalistic repro, which demonstrates the problem?
by (5.1k points)
edited by

I have written and run a simple test, which resembles key parts of your code, on the 6.2 version of our components.
The test is green for LocalFileSystemProvider, MemoryFileSystemProvider, and also for our custom provider (mock).

    public void CreateFile_When_New_File_With_Content_Then_File_Is_Created()
        var parentDir = getFsProviderRoot().GetDirectories().Single(node => node.Name == "New_Dummy_Directory"); ;
        var fileNode = new FileNode("newFile", parentDir);
        fileNode.SetContent(NodeContent.CreateReadOnlyContent(new MemoryStream()));
by (320 points)
reshown by
We're using MemoryFileSystemProvider.

We have Rebex.FileServer.Full 5.0.7731 version, as i remember we receive new version via email or something, so unless we did receive new version from you - we did not update.

Unfortunately it is hard to reproduce, i would like to give you more information, but stacktrace/part of code and NRE itself is all i got. I'll try to retrieve session and .net logs for that moment.
by (5.1k points)
the NRE is thrown every time you are trying to create the file?
How the argument ' DirectoryNode organisationFolder' is obtained? Where and how the organisationFolder variable is created?
Do you use events in the FileSystemNotifier?
Could you please create a KB log as described here?

You can always try the new trial version of components to verify if the problem persists in new version.
By the way: My colleague from the sales department noticed that your email support already expired. The email notification about the expiration of the support contract was sent to Igor Bychko. If Igor Bychko is not the right person to contact you about the support, please drop an email to support@rebex.net to sort these things out. Thanks!
by (320 points)

NRE was thrown one single time so far, there are no clear steps to reproduce since it happened when our client contacted our sftp server on production some time ago, i suppose client did not see any errors or anything, we just received this errors on our backend.

I've updated Rebex library to the latest one, since it seems like we're using library version from 1 years old, so we'll see if it'll reproduce once again.

Regarding license support - i've contacted responsible person and we prolonged the license, thank you very much :)

I suppose we can close this issue until i have some steps to reproduce.

1 Answer

0 votes
by (5.1k points)
selected by
Best answer

thanks for the information. If the NRE will be thrown again, please feel free to contact us.
And thanks for the prolongation of the contract.

And one tip. If you have a new version of our components and if you use the virtual file system as demonstrated in the CreateFiles method, you can find a useful our new API. If you know .NET System.IO (File, Directory...), you are already an expert on our new API.


           using (var memoryProvider = new MemoryFileSystemProvider())
            var memoryProviderRootPath = memoryProvider.GetRootVDirectoryInfo().FullName;
            VDirectory.CreateDirectory(Path.Combine(memoryProviderRootPath, "Archiv"));
            VDirectory.CreateDirectory(Path.Combine(memoryProviderRootPath, "Data", "CurrentData"));
            var oldData = new VDirectoryInfo(Path.Combine(memoryProviderRootPath, "Data", "OldData"));
            using (var archiveFileMs = new VFileStream(Path.Combine(memoryProviderRootPath, "Archiv", "archivefile.dat"), FileMode.CreateNew, FileAccess.Write))
                archiveFileMs.Write(DataGenerator.GetTestData(2048), 0, 2048);

            var myFileTxtPath = Path.Combine(memoryProviderRootPath, "Data", "CurrentData", "myFile.txt");
            using (var currentTxtFile = new VFileInfo(myFileTxtPath).CreateText())
                currentTxtFile.WriteLine("Zvlášť zákeřný učeň s ďolíčky běží podél zóny úlů.");
                currentTxtFile.WriteLine("Příliš žluťoučký kůň úpěl ďábelské ódy.");

            var allText = VFile.ReadAllText(myFileTxtPath);
            TestConsole.Instance.WriteLine("Text from {0}", myFileTxtPath);

            var myDataBinFilePath = Path.Combine(memoryProviderRootPath, "Data", "CurrentData", "myData.bin");
            using (var currentBinaryWriter = new BinaryWriter(VFile.OpenWrite(myDataBinFilePath)))

            var rawBinaryData = StringUtil.ToHexStringLower(VFile.ReadAllBytes(myDataBinFilePath));
            TestConsole.Instance.WriteLine("Raw binary data from {0}: {1}", myDataBinFilePath, rawBinaryData);

            using (var currentBinaryReader = new BinaryReader(VFile.OpenRead(myDataBinFilePath)))
                TestConsole.Instance.WriteLine("Data from myData.bin");