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 / September 2006

Tip: Looking for answers? Try searching our database.

Using System.Windows.Forms types in COM interop modules

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Amit - 12 Sep 2006 22:51 GMT
Hi

I am trying to solve a problem with COM interop from a C# project. My
C# projet is a Windows Forms project and there is a component that
derives from Forms class. The component also implements an interface
that exposes the ShowDialog method of the Forms class to COM clients
with the return type of DialogResult. The module compiles fine in .NET
1.1, but gives compile errors in .NET 2.0.

In my COM component, I import System.Windows.Forms.tlb and also import
my own .net assembly that has been registered for COM interop (using
regasm.exe).

Here is the pseudo code of my project:

[Guid("516768g2-0024-4d7a-9e51-7ae066t4798b")]
public class MyOwnDlg : System.Windows.Forms.Form, IMyOwnDlg
{
       // implementation here
}

[Guid("8428r56c-afab-48d2-921f-17929955fgf6")]
public interface IMyOwnDlg
{
    System.Windows.Forms.DialogResult ShowDialog();
}

When I compile my COM client, I get the following warnings and errors:

warning C4926: 'WinForms::DialogResult': symbol is already defined:
attributes ignored
error C3115: 'id': this attribute is not allowed on 'IMyOwnDlg'
       predefined C++ attributes (compiler internal)(808) : see
declaration of 'id'
       attribute can only be applied to: 'interface member function',
'interface member', 'IDL module'

Can anyone please point me to some documentation about this change or
shed some light on what could be going on and how do I fix this
problem?

Thanks in advance.
Amit - 13 Sep 2006 17:01 GMT
I found what the problem was. I was specifying the embedded_idl
attribute during the #import of the module. I dont understand why it
was causing a problem, but removing it fixed my problem.
Amit - 19 Sep 2006 13:15 GMT
Now I am in a fix...I found out that if I dont import the typelibrary
using the "embedded_idl" attribute, then I cannot use source interfaces
(event interfaces) from the imported typelibrary. I get this error:

error C3706: 'ITestEvents': must be a COM interface to fire COM events

This is annoying and frustrating. If I use embedded_idl attribute, I
get the other compile errors.

Please Help!

Thanks

amitjain
Amit - 20 Sep 2006 12:59 GMT
OK, I fixed the problem. The problem was that when importing
System.Windows.Forms.tlb, I was renaming the namespace from
System_Windows_Forms to WinForms and this was causing a problem for
some reason. After I replaced rename_namespace with no_namespace, my
project compiled without problems.

Rate this thread:







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.