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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:23:18+00:00 2026-06-16T05:23:18+00:00

Background I have an embedded system which runs an application originally written in C++

  • 0

Background

I have an embedded system which runs an application originally written in C++ and compiled in Visual Studio, which results in a single executable and more than 30 DLLs. These libraries cannot be browsed in VS Object Browser or other tools such as P/Invoke Interop Assistant.

Loading some of the DLLs in Dependency Walker shows that all of them are missing some dependencies deep in their dependency tree (cdfview.dll, dwmapi.dll, w32topl.dll, …) but according to this question, that is likely not an issue.

I have some of the source code files, and all of the compiled DLLs. The application currently runs without issue, indicating there are no real dependency issues.

I am trying to call some library functions and eventually make a wrapper using C#, but am unable to successfully import and call even the simplest of functions. I always receive the following error:

Unable to load DLL ‘dllName.dll’: A dynamic link library (DLL)
initialization routine failed. (Exception from HRESULT: 0x8007045A)

Sample Code [EDITED]

From the C++ source code header file I have the following declarations:

#define OB_API __declspec(dllexport) __cdecl 

typedef unsigned long DWORD;  // From windef.h
typedef DWORD OBSTATUS;

OBSTATUS OB_API TestObj(void);

In the C++ source code file the following definition is given (which would seem to always return true):

BOOL WINAPI DllMain(HANDLE  /* hModule */, 
                      DWORD   ul_reason_for_call, 
                      LPVOID  /* lpReserved */
                      )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    case DLL_PROCESS_DETACH:
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
        break;
    }
    return TRUE;
}

In my C# application class, I add the following declaration:

[DllImport(@"dllName.dll", CallingConvention=CallingConvention.Cdecl)
public static extern ulong TestObj();

The DLL and C# application binary reside in the same directory.

Questions

From researching the error, it seems there is a large number of reasons this particular exception could be thrown and I was wondering how I could further troubleshoot this type of issue.

Is there any way to get more detailed information on why the initialization routine failed?

(Note: target system is running .NET framework 2.0)

  • 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-16T05:23:19+00:00Added an answer on June 16, 2026 at 5:23 am

    The DLL you are loading contains a DllMain() function. That’s pretty common, such a function initializes the state of the DLL. Windows makes sure that this function is called whenever the DLL gets loaded, it will happen automatically the first time you pinvoke a function exported by that DLL.

    Problem is, that function returned FALSE to indicate that it could not properly initialize the DLL. That of course does not give a wholeheckofalot of information about why it returned FALSE. Windows can’t do anything but generate error 1114, ERROR_DLL_INIT_FAILED. If the DLL itself doesn’t output any diagnostic then you can’t do anything but debug the code. Start with Project + Properties, Debug tab, tick the “Enable unmanaged code debugging” option.

    Fingers crossed that you see a message in the Output window. Odds are not very good. If you don’t have the source code for the DLL then you’ll need the help of the vendor or author of the DLL. Give him a copy of a test project that fails like this.

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

Sidebar

Related Questions

Background of project -> I have to upgrade the Linux embedded system remotely. This
Inside of my WPF application, I have embedded a WebBrowser control, which in turn
Background: We have an embedded system that converts linear positions (0 mm - 40
Background I have two lists, the first is items which contains around 250 tuples,
Background : I have a few different threads which each need to write to
Background I have a dimension table that has a single record for each day.
First three elements of the background: I have created a Excel Template which is
I have flash object embedded to my page and it should act as background
I have a script embedded in a page, which is as follows: <script type=text/javascript>
I have a Windows CE embedded 6.0 application that opens another app in the

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.