0

I have aDLLbased in .NET which I expose to native applications using COM. It seems to run fine most of the time, however, using logs, I have seen that on some occasions, the DLL, when doing some work for an application, say Application A, gets interrupted, and instead takes up the work for Application B, which starts from the beginning. The work for Application A is entirely abandoned.

TheDLL is registered forCOMof course, and is present in the GAC.

I am new to COM, and I suppose this has something to do with the Apartment model, single threaded Vs. Multi threaded?I had read in the beginning that if one uses.NETcomponents and have them exposed as COMobjects, then one need not worry about it most of the times.

Is it likely that it is indeed the Apartment which is causing this issue, and what can I do to fix this? Is there an attribute to declare a particular apartment model?

Thanks..

user1173240
  • 1,455
  • 2
  • 23
  • 50
  • how do you call the DLL in your applications? – Cerveser Jan 19 '16 at 14:01
  • This DLL is registered for COM, and put in GAC. Native application is built with the .TLB of this DLL. Then in the native application, I use a COM pointer to access the functions. `static CLSInterOpLibrary::CLSInterOpInterface *com_ptr; `CLSInterOpLibrary::CLSInterOpInterfacePtr p(__uuidof(CLSInterOpLibrary::CLSInterOpClass)); if (p == nullptr) return false; com_ptr = p;` – user1173240 Jan 19 '16 at 14:08
  • No, nothing to do with apartments. Each process gets its own copy the CLR and its own GC heap, there is no possible sharing. You would have to make a mistake in your code that causes them to use the same backing store, like a file or a dbase. – Hans Passant Jan 19 '16 at 14:21
  • If each application has its own DLL, and own copy, then I don't understand how the work which was being done by Application A would be entirely abandoned and work for application B taken up. The COM DLL does not access a file, or a database, but it does call another COM based DLL. – user1173240 Jan 19 '16 at 14:27

0 Answers0