Re: C# class forward declaration, possible?
From: François Côté (FranoisCt_at_discussions.microsoft.com)
Date: 02/01/05
- Next message: Sean McKaharay: "AxWebBrowser"
- Previous message: trint: "Can DefaultPageSettings.PaperSource contain 3 seperate values?"
- In reply to: Nicholas Paldino [.NET/C# MVP]: "Re: C# class forward declaration, possible?"
- Next in thread: cody: "Re: C# class forward declaration, possible?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 1 Feb 2005 14:01:05 -0800
Hi Nicholas and thanks for your quick reply,
So I guess the answer for forward declaration in C# is no?? :-)
The info you provided does not help me. The circular dependency is not a
*real* dependency because one of the dependency is for creating a COM objetc.
We had this same problem in C++ before: we have a utils dll that all other
dll have a real dependency on. At some point, we needed to call one of our
own COM object from this utils.dll Since the dll that hosted the COM object
depended on the utils dll, we couldn't just create a dependency in DevStudio.
Instead, we created a new project that contained the IDL file of the COM dll
and both projects depended (in DevStudio) on this IDL project. So the build
sequence was:
- the IDL project
=> creates the COM header file (interface + class definition)
- the Utils project (uses COM objects from next project)
- the COM implementation project (depends on Utils)
I have the exact same problem now (but with four Dlls, two in C# and two in
C++)
In C#, I have the interface in an assembly so it acts as an equivalent to
the IDL project above, except, because there is no class definition in the
resulting TLB, the next project in line can't compile.
If I could just add a class declaration to this assembly, my problem would
be solved, can it be done in C#?
Thanks for your support, it's really appreciated,
"Nicholas Paldino [.NET/C# MVP]" wrote:
> François,
>
> I don't think that you need to change your C# code or the TLB produced
> by calling TLBEXP. Rather, you need change how they are referenced in your
> C++. If you are using the #import statement, then you can use the exclude
> attribute to indicate what types to exclude (in this case, the interface
> definition), as well as other attributes to control how the type information
> is imported.
>
> Hope this helps.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mvp@spam.guard.caspershouse.com
>
> "François Côté" <FranoisCt@discussions.microsoft.com> wrote in message
> news:F7FEC6AC-2A1C-4986-8D17-8070B15AF593@microsoft.com...
> > I'm generating a TLB from one of my assemblies that contains an interface
> > declaration. The class that implements this interface is in another
> > assembly.
> > I import this tlb in my C++ code to create instances of my C# classes. The
> > problem I have is that I need to specify the class in my CoCreate call in
> > C++.
> >
> > If I try to generate a TLB for the assembly that does contains the class
> > and
> > interface implementation, I end up with a circular dependency problem
> > between
> > my C++ and C# projects.
> >
> > Is there any way I can declare the C# class along with the interface (a
> > bit
> > like a IDL file) in that first assembly so the class is defined in the
> > TLB?
> >
> > Thanks,
> >
> >
>
>
>
- Next message: Sean McKaharay: "AxWebBrowser"
- Previous message: trint: "Can DefaultPageSettings.PaperSource contain 3 seperate values?"
- In reply to: Nicholas Paldino [.NET/C# MVP]: "Re: C# class forward declaration, possible?"
- Next in thread: cody: "Re: C# class forward declaration, possible?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|