Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Using C# DLL in C++ App - nearly there...

Using C# DLL in C++ App - nearly there...

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++dotnethelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mike Grove
    wrote on last edited by
    #1

    I realise there is a lot of stuff out there relating to this need, but I'm still struggling...so any pointers to where I'm going wrong are appreciated. I'm attempting to use the ModbusTCP DLL (available elsewhere on these forums) in my C++ console test app (with CLR support enabled) and it compiles ok. However, it crashes even before execution even gets to the first printf(...). Code is as follows, error details are after the code;

    #include "stdafx.h"
    #include "conio.h"

    #using "ModbusTCP.dll" // TCP Master implementation
    using namespace ModbusTCP;

    int _tmain(int argc, _TCHAR* argv[])
    {
    printf( "About to create MBmaster..." );
    try
    {
    // Create new modbus master and add event functions
    Master^ MBmaster = gcnew Master( "192.168.100.1", 23 );
    printf( "MBmaster created ok" );
    }
    catch ( ... )//SystemException error )
    {
    //MessageBox.Show( error.Message );
    printf( "Error caught" );
    }

    while ( !\_getch() )
    	;
    return 0;
    

    }

    Error dialog contains the following text: "An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module. Could not load file or assembly 'ModbusTCP, etc, or one of its dependencies".

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups