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

  • SEARCH
  • Home
  • 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 6543521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:21:25+00:00 2026-05-25T11:21:25+00:00

I just modified my C++/CLI project to change the way it was parsing its

  • 0

I just modified my C++/CLI project to change the way it was parsing its config.ini text file. But it still accesses the file on the disk just as before:

StreamReader ^sr = gcnew StreamReader(CONFFILE_NAME);
String ^rdfl = sr->ReadToEnd();
sr->Close();

Now it won’t run outside of the VS2008Express environment. It is a WinForm pretending to be a service and should stay in the notification tray but instead it just flashes its default icon there until I roll my mouse over it, a sure sign it has already terminated abnormally. The default icon should immediately be updated btw so I will check upto that point again. I’ve just tried a clean and rebuild.

Thanks.

_EDIT_

It runs fine if the config file is not there or is incompatible – a window appears and I enter the correct config and off she goes. But it reloads config data from a file from within VS2008 and it used to from without (albeit with a major logical error in the coding).

Here’s the code immediately following that posted above:

    int fore = 0;
    int aft;
    while (statsRead < 4) {
        fore = rdfl->IndexOf(':', aft)+1;
        if (fore == -1) break;
        aft = rdfl->IndexOf('\n', fore);
        if (aft == -1) break;
        if (statsRead == 0) str1 = rdfl->Substring(fore, aft-fore)->Trim();
        else if (statsRead == 1) str2 = rdfl->Substring(fore, aft-fore)->Trim();
        else {
            String ^tmpIntStr = rdfl->Substring(fore, aft-fore)->Trim();
            int tmp_int;
            if (Int32::TryParse(tmpIntStr, tmp_int)) {
                switch (statsRead) {
                    case 2: int1 = tmp_int; break;
                    case 3: int2 = tmp_int; break;
                }
            } else break;
        }
        ++statsRead;
    }
}

afterwards any remaining stats are given default values which work in my case, apart from the first which triggers the window.

_EDIT_

I’ve updated the above with try and catch blocks as advocated by Hans and also the MSDN literatur for StreamReader but still it fails, the stack trace (thanks, Hans) indicates the fault is my while statement (no thanks, MS)

if (File::Exists(CONFFILE_NAME)) {
    String ^rdfl;
    try {
        StreamReader ^sr = gcnew StreamReader(CONFFILE_NAME);
        try{
            rdfl = sr->ReadToEnd();
        } finally {
            if ( sr )
                delete (IDisposable^)sr;
        }
    } catch (Exception ^ex) {
        MessageBox::Show(ex->Message);
    }
    int fore = 0;
    int aft;
    while (statsRead < 4) {
        fore = rdfl->IndexOf(':', aft)+1;
        if (fore == -1) break;
        aft = rdfl->IndexOf('\n', fore);
        if (aft == -1) break;
        if (statsRead == 0) str1 = rdfl->Substring(fore, aft-fore)->Trim();
        else if (statsRead == 1) str2 = rdfl->Substring(fore, aft-fore)->Trim();
        else {
            String ^tmpIntStr = rdfl->Substring(fore, aft-fore)->Trim();
            int tmp_int;
            if (Int32::TryParse(tmpIntStr, tmp_int)) {
                switch (statsRead) {
                    case 2: int1 = tmp_int; break;
                    case 3: int2 = tmp_int; break;
                }
            } else break;
        }
        ++statsRead;
    }
}
  • 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-25T11:21:26+00:00Added an answer on May 25, 2026 at 11:21 am

    This is typically a simple mistake, like CONFFILE_NAME not being a full path name and the default working directory not set where you hope it is. Focus on getting a debugger attached. That’s easy in .NET, use System::Diagnostics::Debugger::Launch() in your Main() method for example. And write an event handler for AppDomain::CurrentDomain->UnhandledException so that exceptions don’t fall in the bit bucket without notice. Be sure to remove try/catch statements that shouldn’t be there.

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

Sidebar

Related Questions

I just started working with play, and I modified the way I'm doing a
I use this http://goo.gl/d3vLW code for my project, but it's not working the way
Just what the title says, I need to change the password for an existing
Just installed the latest SDK for iPhone 2.1. When I go to File ->
I have the following model where I just modified my IEntity interface to take
Possible Duplicate: How do I find the last modified file in a directory in
I just modified an older code and now nothing seems to be working. Could
Is there a way to watch a file in VBA (which is essentially VB6),
I am working on localhost(XAMPP) with codeigniter 2.1.0, I just modified welcome_message view with
I've just modified a method for handling my DDD commands (previously it had no

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.