Note that there are some explanatory texts on larger screens.

plurals
  1. POUnmanaged lib in managed executable causing managed exceptions
    primarykey
    data
    text
    <p>I'm having a problem with mixing managed and unmanaged code. I have created two projects under a single solution in Visual Studio 2008 under Vista x64 SP1. One of them does not have CLR support and is a static library. My second project is compiled as an executable with CLR enabled. It depends on the first static library, and passes WinForms events to it.</p> <p>When I start the application without debugging, I get an exception, I put the info that I get from the exception here: <a href="http://pastebin.com/f46ad1211" rel="nofollow noreferrer">http://pastebin.com/f46ad1211</a>.</p> <p>Here is the code of the unmanaged lib that is run:</p> <pre><code>void manager::init() // &lt;-- Called from the .exe project { this-&gt;log.open("C:\\development\\log.txt"); this-&gt;storage = storage_manager(&amp;(this-&gt;log), &amp;(this-&gt;settings)); this-&gt;storage.load_settings(); } </code></pre> <p>&amp;</p> <pre><code>void storage_manager::load_settings() { this-&gt;error_check(sqlite3_open("settings.db", &amp;(this-&gt;db_settings_p))); sqlite3_stmt* read_settings; this-&gt;error_check(sqlite3_prepare_v2(this-&gt;db_settings_p, "SELECT name, value FROM settings", 1024, &amp;read_settings, NULL)); int step_code; std::string name; std::string value; while(true) { step_code = sqlite3_step(read_settings); if(step_code == SQLITE_DONE) { break; } else if(step_code == SQLITE_ROW) { name = std::string(reinterpret_cast&lt;const char*&gt;(sqlite3_column_text(read_settings, 0))); value = std::string(reinterpret_cast&lt;const char*&gt;(sqlite3_column_text(read_settings, 1))); (*(this-&gt;settings))[name] = value; } else { this-&gt;error(); } } sqlite3_reset(read_settings); sqlite3_finalize(read_settings); } </code></pre> <p>&amp;</p> <pre><code>void storage_manager::error_check(int rc) { if(rc) { this-&gt;error(); } } void storage_manager::error() //Sure of error { std::string error_msg; error_msg = "Storage Manager: SQLite Error ("; error_msg += sqlite3_errcode(this-&gt;db_p); error_msg += ") - "; error_msg += sqlite3_errmsg(this-&gt;db_p); this-&gt;log-&gt;write(error_msg.c_str(), error_msg.length()); this-&gt;log-&gt;flush(); } </code></pre> <p>I can't see why I'm getting a managed (System.BlahBlahBlah) exception in an unmanaged library. Is there any way to get the two to be totally separate?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload