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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:28:57+00:00 2026-06-18T08:28:57+00:00

In my project I have an unmanaged native C++ dll and a C# application.

  • 0

In my project I have an unmanaged native C++ dll and a C# application. I am trying to import a function from the unmanaged dll using DllImport but I keep getting a DllNotFoundException.

Here is my code that calls the DLL.

using System.Runtime.InteropServices;
namespace TestApp
{
  public delegate void UpdateDelegate(string s);
  class Program
  {
    [DllImport("CGPUnmanagedLibrary.dll")]
    internal static extern int parse_raw_gsod_file( 
      [MarshalAs(UnmanagedType.LPStr)]                                               
      string filePath,
      int minTemp, 
      UpdateDelegate callBack);

    static void Main(string[] args)
    {
      UpdateDelegate myCallBack = new UpdateDelegate(Program.Report);
      string path = @"C:\Creative Solutions\Projects\Clyde's Garden Planner\Frost Data Database\GSOD Data\GSOD_RAW_DATA\1992\gsod_1992.txt";
      int result = parse_raw_gsod_file(path, 32, myCallBack);
      Console.Write("Parse completed with exit code: " + result.ToString());
      Console.ReadLine();
    } // end main function

    public static void Report(string msg)
    {
      Console.Write("Message is ");
      Console.WriteLine(msg);
    }

  } // End class
} // end namespace

I tried copying the DLL to the app output directory but it still can’t find it. I also tried adding the DLL project as a reference but I get a popup window saying it can’t be added. How do you properly link an unmanged DLL to a managed application?

Update – Here is the full error:

Unable to load DLL 'CGPUnmanagedLibrary': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Update 2 – I know for sure that the DLL is in the same directory as the .exe trying to load it. This makes me think there is a dependency in the DLL that isn’t getting loaded. I’m only using basic C++ libraries in the DLL (string, math, iostream, etc). Any ideas what could not be loading and why?

Update 3 – Tested with Dependency Walker
Loading my unmanaged C++ DLL in dependency walker showed no errors. I also tried to open my executable in dependency walker and it showed errors loading two DLLs: GPSVC.DLL and IESHIMS.DLL – doesn’t make any sense because I am only using standard c++ libraries in my code. I think it may have something to do with the fact that I have a managed C++/CLI DLL trying to load the unmanaged DLL as well (I was trying to implement some C++/CLI wrappers). Anyway, I have since started a new VS solution and moved on. See my answer.

  • 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-18T08:28:58+00:00Added an answer on June 18, 2026 at 8:28 am

    First I want to thank everyone for their help. Unfortunately I never did solve this issue (see edits in my main question). The answer turned out to be starting a totally new Visual Studio solution and creating two new projects: C# app and C++ dll. I did away with the need for wrappers as I am now just marshaling two main functions.

    Thanks again.

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

Sidebar

Related Questions

I have an unmanaged dll that contains a function to read a data from
We have a big C++ project that's compiled as native unmanaged code. We need
I have project Emle in Launchpad . I set it to import from emle.svn.sourceforge.net
I have written an C++/Cli wrapper for a native C++ dll, but when I
I have a solution with an unmanaged c++ dll project in it and a
I have a WPF click-once application that makes use of an unmanaged dll. When
I have a vb.net dll which I imported in an unmanaged c++ project. I
I have a managed c++/cli project that wraps an unmanaged dll. I load the
I'm importing several unmanaged c++ DLL's into my project however the imported DLLs have
i have an application project that both managed and unmanaged code runs and i

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.