Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / January 2005

Tip: Looking for answers? Try searching our database.

Nasty COM Interop Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sebastien Lange - 13 Jan 2005 14:50 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.