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 8773531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:19:08+00:00 2026-06-13T18:19:08+00:00

I know there is a few threads here that have been asked about the

  • 0

I know there is a few threads here that have been asked about the same subject but unfortunately non of them has helped me.

I am using a wrapper for unmanaged c++ code in my .net application, in the unmanaged Dll there’s a function “LoadLayoutFile()” where it loads a custom formatted file with extension (.lyt), my .net application has a loop where it calls that function based on array items count. If this array has one item, the application run smoothly without any problem, however if it had more than one item, the application crashes immediately without, of course, any chance to figure out what happened, but that also doesn’t happen all the time also, which is very much confusing.

I tried DebugDiag, Windbg to track the crash but I didn’t succeed with that.
I also tried to fix my unmanaged code by adding destructors, exception handling, I have also tried to put garbage collectors (in the .net application) where they should be, non of these have worked. I would love to know what’s going on? or at least to be able to catch an error!

Here’s LoadLayoutFile() in c++ dll:

int CMKCRD32App::LoadLayoutFile(LPCSTR lpszFileName)
{
    try
    {
        int     nRetVal = MCRC_SUCCESS;
        CFile   file;
        WORD    wVersionNumber;

        // Add New Layout to the Layouts List
        nRetVal = AddLayout();

        // If Layout not added Correctly return Error Code
        if(nRetVal<0)
            return MCRC_MAXLAYOUT_REACHED;

        if(file.Open(lpszFileName,CFile::modeRead|CFile::shareCompat))
        {
            CArchive    ar(&file,CArchive::load);

            ar >> wVersionNumber;

            m_pCard[nRetVal]->Serialize(ar,wVersionNumber);

            ar.Close();
            file.Close();

            m_pCard[nRetVal]->OffsetItemsByMargin(TRUE);
        }
        else
        {
            nRetVal = MCRC_ERROROPENFILE;
        }

        return nRetVal;
    }
    catch(char *str)
    {
        throw str;
    }
}

The AddLayout()

int CMKCRD32App::AddLayout()
{
    int nIndex;
    try
    {
        for(nIndex=(_MAX_LAYOUTS_-1); nIndex >= 0; nIndex--)
            if(m_pCard[nIndex]==NULL)
                break;

        if(nIndex>=0)
        {
            m_pCard[nIndex] = new CLYT_Card();

            if(!m_pCard[nIndex])
            {
                nIndex = -1;
            }
        }

        return nIndex;
    }
    catch(char *str)
    {
        throw str;
    }

}

And here exactly where it crashes in .net application (sometimes):

CardLayout cardLayout = new CardLayout(); // Wrapper

foreach(var item in x)
   int layout = cardLayout.LoadLayoutFile("cc.lyt");
  • 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-06-13T18:19:10+00:00Added an answer on June 13, 2026 at 6:19 pm

    Your library looks fine, may be it’s a performance thing, you may have a large stack trace. If it’s not crashing when you call it once and it does when you call it more than that (sometimes like you said) it could be because of huge objects in memory especially if your library has some image processing job to do (I’m assuming that because I have seen layout file) and it doesn’t destroy them properly.

    My advice to you is to try to separate your desktop application code from the part that calls that library, may be you should try to let it work on another thread or try to put that code segment in a console application and call that console application from your desktop application, that will separate them from each other and if any crash may happen it will not affect your desktop application.

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

Sidebar

Related Questions

I know there have been a few threads on this before, but I have
There have been a few threads on this topic but none have been able
I know there are few threads about this topic. But what really confused me
I know that there are a few threads open regarding this topic, but I'm
I know there's a few threads on here about passing variables to the template
So I know there is a few templating engines out there, but I thought
First of all, I know there are a few quite similar questions here on
I know that there are a few similar questions and I googled a lot
Hey I know there are already a few posts about this - yet I
I know how to use locks in my app, but there still few things

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.