Including Lua in C++ DLL makes it incompatible with C#? -


i'm trying make ui c# using wpf calls unmanaged c++ .dll. i've tried using platform invoke method, , compiling c++ code /clr option, nicer. both of these methods work fine, until c++ .dll uses code includes standard lua header files. sure, c++ code works fine when compiled .exe, , when .dll called c++ project.

just testing, c# side first code block below when using pinvoke :

namespace thermosim_ui {     public class cppinterface     {         [dllimport("thermosimdll_1.2.dll")]         public static extern int testpassstring();          public cppinterface()         {             testpassstring();         }     } }     

and c++ .dll has header :

#ifdef thermosimdll_exports #define thermosimdll_api __declspec(dllexport)  #else #define thermosimdll_api __declspec(dllimport)  #endif  extern "c" {     thermosimdll_api int testpassstring(); } 

as say, works until have file in c++ .dll uses lua includes :

extern "c" { #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include "luajit.h" } 

ah, , c# error :

a first chance exception of type 'system.windows.markup.xamlparseexception' occurred in presentationframework.dll  additional information: invocation of constructor on type 'thermosim_ui.mainwindow' matches specified binding constraints threw exception. 

additionally in output window there :

a first chance exception of type 'system.badimageformatexception' occurred in thermosim_ui.exe first chance exception of type 'system.reflection.targetinvocationexception' occurred in mscorlib.dll first chance exception of type 'system.reflection.targetinvocationexception' occurred in mscorlib.dll first chance exception of type 'system.xaml.xamlobjectwriterexception' occurred in system.xaml.dll first chance exception of type 'system.windows.markup.xamlparseexception' occurred in presentationframework.dll additional information: invocation of constructor on type 'thermosim_ui.mainwindow' matches specified binding constraints threw exception. program '[8048] thermosim_ui.vshost.exe: managed (v4.0.30319)' has exited code -1 (0xffffffff). 

badimageformatexception seems have things .dll having different build configuration, mixing x64 x86 or something. anyways haven't figured out yet. http://msdn.microsoft.com/en-us/library/system.badimageformatexception(v=vs.110).aspx

has encountered this, or have idea why .dll becomes incompatible c#?

following @schollii's advice did trick: if build lua myself visual studio, works. post helped, small modification: lua in visual studio 2012?.

  1. download lua files lua.org/download.html
  2. made new visual studio project creates library. made static library.
  3. remove interpreter file lua.c because conflicts luac.c
  4. compile same settings c++ dll, x64, release.

now c# project can call c++ dll.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -