Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>int Hoop(); </code></pre> <p>is an incorrect translation of the IDL declaration into C#. The correct one would be </p> <pre><code>void Hoop(); </code></pre> <p>.NET wraps COM result codes (HRESULT) into correspondent C# exceptions. For example if you return E_NOTIMPL in C++ code, .NET runtime will throw an instance of the NotImplementedException class</p> <p>*<strong><em>UPDATE</em>*</strong></p> <p>According, to <a href="http://msdn.microsoft.com/en-us/library/system.threading.thread.apartmentstate.aspx" rel="nofollow">MSDN</a>, the main application thread is initialized to 'MTA' by default. Your object CSimpleObject is configured to reside in the 'STA'. In order to make cross-apartament calls, the COM runtime will use <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms692621%28v=vs.85%29.aspx" rel="nofollow">your implementation of the proxy/stub to marshall</a> the corresponding data. </p> <p>The runtime needs a valid proxy/stub implementation which is generated by MIDL from your IDL file. </p> <p>You have marked the 'Hoop' function as "Local". This means that MIDL will not generate any marshalling code for this method, that is why you get an exception.</p> <p>One should remove the 'local' attribute since it is designed to be used only inside the server where an object is implemented. But as a possible solution I may suggest you to use the object from a thread configured to run in STA. Anyway, this is a bad approach, since it doesn't guarantees, that no marshalling will be involved.</p> <p>You may mark your main thread to run in STA as follows:</p> <pre><code>[STAThread()] static void Main(string[] args) { ... } </code></pre> <p>I hope this will help you to solve the problem.</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.
    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