Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 637283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:36:25+00:00 2026-05-13T20:36:25+00:00

I run into a very strange problem in my C# 2.0 WinForms app and

  • 0

I run into a very strange problem in my C# 2.0 WinForms app and I’m not even sure if its worth asking SO, because the problem occurs in a strange setup and I don’t think that you could reproduce it without my sources, but I’m totally out of ideas.

I have a Form with a TreeView on the left and an ListView on the right. The TreeView shows all available files and subfolders from a specific folder(which contains documents i need for my app). If a Folder is selected the ListView shows all files and subfolders from the selected folder. At startup I populate the TreeView form the folder and after that I select the first TreeNode by code(in my case it’s an folder). After that the Content of the TreeView looks like this:

-folder
   -file1
   -file2

Selecting the folder triggers the AfterSelecedEvent of the TreeView. Because a folder was selected I populate the ListView using the following methode:

private void fillOverview(FAFolder folder)
{
    lv_overview.Items.Clear();
    ListViewItem item;
    foreach (FAFile file in folder.sortedContent)
    {
        if (file is FAFolder)
        {
            item = new ListViewItem(file.Name, "Folder"); //exception got thrown here
        }
        else
        {
            item = new ListViewItem(file.Name, file.Name);
        }
        item.Tag = file;
        lv_overview.Items.Add(item);
    }
}

As you can see there is no subfolder, so the line item = new ListViewItem(file.Name, "Folder"); should never be touched in this setup, but every now and then a NullReferenceException got thrown. If I wrap this line with try/catch the exception got thrown inside the catch block. I tried checking everything if it’s null or not, but ther were no nullreferences. Or if I add a MessageBox right before this line the exceptions got still thrown and no MessageBoxpops up. This brings me to the conclusion that the execption stacktrace is wrong and/or this exceptions comes from an other Thread or something like that.

I’m a very optimistic person and I know how clever the SO community can be, but I don’t think that anybody can point out what the problem is. So what i’m actuallly looking for are hints and advices how i could find and debug the cause of this strange behavior.

EDIT:

internal abstract class FAFile
{
    internal string Name;
    internal readonly FAFolder Parent;
    internal FAFile(FAFolder parent)
    {
        this.Parent = parent;
    }
}

internal sealed class FAFolder : FAFile
{
    internal readonly IDictionary<string, FAFile> Content = new Dictionary<string, FAFile>();
    internal FAFolder(FAFolder parent, string name) : base(parent)
    {
        this.Name = name;
    }
}

internal sealed class FADocument : FAFile
{
    public readonly string Path;
    public FADocument(FAFolder parent, string path): base(parent)
    {
        this.Path = path;
        this.Name = System.IO.Path.GetFileNameWithoutExtension(path);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:36:26+00:00Added an answer on May 13, 2026 at 8:36 pm

    A co-worker of mine just found the answer(probably). I use a Thread to load the ImageList to the ListView from the HDD and this thread sometimes freezes and if i assign a ImageKey it fails. That’s no answer why the exception is uncatchable or why it’s thrown at this (unreachable) line. But i strongly belive that this is the cause of the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’ve run into a very strange (to me) problem with the var keyword. I’ve
I have run into a very strange behaviour I can’t make sense of. I
I seem to run into this very often. I need to build a Hash
I'm writing a very simple text editor and have run into a somewhat minor
I often run into the following problem. I work on some changes to a
I've run into a strange syntax in Boo Language Guide : setter = {
I've run into a problem where I make changes to a few JavaScript files
I come into a strange problem in pthread programming I've compiled the following code
I want to query a result from a table. The problem I run into
I run into similar codes like this all the time in aspx pages: <asp:CheckBox

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.