Note that there are some explanatory texts on larger screens.

plurals
  1. POC# managed COM dll in C++ unmanaged project - Strange Entity Framework Problems
    primarykey
    data
    text
    <p>I'm implementing a C# project in a C++ unmanaged solution through COM. the C# project uses an EntityFramework to give back values about the database.</p> <p>When we call the "Test()" method from an UnitTest C# project in this Solution, everything goes fine. When we call it from the unmanaged C++, an Exception occurs in the called "Test()" method.</p> <p>The exception: </p> <pre><code>No connection string named 'Entities' could be found in the application config file. </code></pre> <p>The location in the unmanaged C++ where we call the "Test()" method:</p> <pre><code>AServer::Server_InterfacePtr p(__uuidof(AServer::Server)); long res = p-&gt;Test(); // gives 1337, WRONG: it should give the count of users </code></pre> <p>The called method in the C# project:</p> <pre><code> public int Test() { TextWriterTraceListener myTextListener = new TextWriterTraceListener(@"C:\log.txt"); Trace.Listeners.Add(myTextListener); try { Entities model = new Entities(); ObjectResult&lt;UserGetAll_Result&gt; res = model.UserGetAll(); return res.Count; } catch (Exception e) { Trace.WriteLine(e.Message); // writes out "No connection string named 'Entities' could be found in the application config file." return 1337; } } </code></pre> <p>The Unittest method:</p> <pre><code> [TestMethod] public void TestMethod1() { Server server = new Server(); var res = server.Test(); // OK: gives the count of users } </code></pre> <p>Is there anyway we can solve this? We thought of giving the ConnectionString as parameter in the "Test()" method to use it in the model's constructor, but apparantly <code>Entities</code> doesn't accept a ConnectionString as parameter in it's constructor.</p> <p>The connectionstring has been provided in the C# projects (incl. the unittest) in <code>App.Config</code>. The used version of the AntityFramework is 5. The solution targets frameworkversion 4.0.</p> <p>Methods who don't use the EntityFramework work just fine.</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.
 

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