Hi,
I'm having a very weird problem with a wrapper I made around a com
object. While creating the wrapper I was testing it by means of a button
on a test form, and the COM wrapper worked just fine.
It was actually meant to be used in a multi-threaded environment. Now,
the library still works, except for 4 methods, all of which expect a
path to a file. I'm getting a 'could not open file' or 'could not create
file' on the following methods:
[ComVisible(true),
ComImport,
Guid("07759AE1-4DF1-11d4-871F-0050DA816754"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPVMediaConfig {
...
[PreserveSig]
int SaveProfile([In,MarshalAs(UnmanagedType.LPWStr)]string profileFile);
[PreserveSig]
int LoadProfile([In,MarshalAs(UnmanagedType.LPWStr)]string profileFile);
[PreserveSig]
int SaveSession([In,MarshalAs(UnmanagedType.LPWStr)]string sessionFile);
[PreserveSig]
int LoadSession([In,MarshalAs(UnmanagedType.LPWStr)]string sessionFile);
...
}
Although the methods execute, I'm getting these errors, although the
files are garanteed to be there and the methods are called in exactly
the same way as when testing the COM wrapper.
So these methods work fine when executed in a button handler, but not
when executed on a different thread. It first I thought it was the
ApartmentState, so I tried setting this to STA on the thread, but this
obviously didn't work.
Any help is greatly appreciated...
Thanks in advance.
Sebastien
Alcatel Namur
Belgium
Sebastien Lange - 13 Jan 2005 16:07 GMT
Hi,
I did some more tests on this and seems that it was in fact an
ApartmentState problem. Setting it to STA solved the issue, but created
another one... now the thread blocks when I use the object in more than
one thread!
Any ideas anyone?
Thanks,
Wouter
> Hi,
>
[quoted text clipped - 41 lines]
>
> Belgium