Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing C# COM in unmanaged C++ project -> First-chance exception at 0x7697C41F (KernelBase.dll)
    primarykey
    data
    text
    <p>I'm trying to call methods from a C# COM project in an unmanaged Visual C++ solution, but I keep getting the next error</p> <pre><code>First-chance exception at 0x7697C41F (KernelBase.dll) in Program.exe: 0x04242420 (parameters: 0x31415927, 0x6F310000, 0x00BBDAE8). </code></pre> <p>at the next piece of code</p> <pre><code>SalesForceNew::IMyObjectClassPtr p; p.CreateInstance(__uuidof(SalesForceNew::TestObject)); // error SalesForceNew::MyObject mo = p-&gt;getObject(1, "a"); </code></pre> <p>However the value of <code>mo</code> is as expected (5, "aa").</p> <p>I import the tlb-file with this line of code:</p> <pre><code>#import "C:\Users\Bob\Desktop\ComTest\SalesForceNew\bin\x86\Debug\SalesForceNew.tlb" named_guids </code></pre> <p>The C# project is as follows:</p> <p>The interface:</p> <pre><code>using System.Runtime.InteropServices; namespace SalesForceNew { [ComVisible(true)] [Guid("22901ACD-CA30-4D3E-B84B-73B707026AE5")] public interface IMyObjectClass { MyObject getObject(int i, string s); } [ComVisible(true)] [StructLayout(LayoutKind.Sequential)] public struct MyObject { public int Getal; public string Text; } } </code></pre> <p>the class implementing the interface:</p> <pre><code>using System.Runtime.InteropServices; namespace SalesForceNew { [ClassInterface(ClassInterfaceType.None)] [Guid("234A2A35-F270-458D-A67B-C834EB794B27")] [ComVisible(true)] public class TestObject : IMyObjectClass { public MyObject getObject(int i, string s) { return new MyObject() { Getal = i * 5, Text = s + s }; } } } </code></pre> <p>I checked the options <code>Register for COM interop</code> and <code>Make assembly COM-Visible</code> in the properties of the C# COM project.</p> <hr> <p>UPDATE: the error won't come up if we change the frameworkversion of the C# COM project to 2.0, 3.0 or 3.5. It only shows up when the frameworkversion is 4.0 or 4.5.</p>
    singulars
    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.
 

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