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

Tip: Looking for answers? Try searching our database.

Can RCW and CCW be used together?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TW - 12 Jul 2006 01:28 GMT
We're C# .NET developers who must use an ActiveX container (not IE) to
create and contain our components. We'd like both the component and the
client to be C# .NET code.

But, it appears that you cannot do this. To do this, the RCW of my
client code would have to be able to talk to the CCW of my component. I
can't see how to do this. And, when I try to add my .tlb as a reference
to a .Net assembly, I get an error saying that a CLR assembly cannot be
used in this way.

Is there any solution short of changing the component code to C++ and
ATL? Is it possible to use .NET remoting to communicate between my .NET
client and .NET component even though it is an ActiveX container that
creates the component?

--TW
Marcus Heege - 12 Jul 2006 08:04 GMT
Hi TW,

COM interop is smart enough to not create a RCW that talks to a CCW to talk
to your .NET object, but to give you a direct reference to the .NET object
instead. There is no need to reference other things apart from your
problem-domain specific assemblies and the assemblies for the RCW-Interop
type info (e. g. the Primary Interop Assemblies).

Marcus Heege

> We're C# .NET developers who must use an ActiveX container (not IE) to
> create and contain our components. We'd like both the component and the
[quoted text clipped - 12 lines]
>
> --TW
TW - 12 Jul 2006 14:12 GMT
This is what I started out assuming. I can successfully add my .NET
component project reference to my client project and build.

I can successfully create an instance of my .NET component via
automation calls to the ActiveX container. Then, I cast the created
object to my class. Upon accessing any property or method in this
object, I get a Remoting exception:

"This remoting proxy has no channel sink which means either the server
has no reg
istered server channels that are listening, or this application has no
suitable
client channel to talk to the server."

I can access properties and methods in the object returned from the
ActiveX container, just not on my object class. I can also access
properties and methods of non-.NET ActiveX controls provided by the
vendor after I've cast them to the right type.

Here's a snippet of VB code as an example of what I'm doing:

       ' Start IADS
       Dim iads As IadsAutomationLib.Application
       iads = CreateObject("Iads.Application")

       ' Load configuration
       Dim iadsConfigFile As String
       iadsConfigFile = "pfConfig"
       iads.Configuration.LoadConfiguration(iadsConfigFile)

       ' Create an analysis window
       Dim aw As IadsAutomationLib.AnalysisWindow
       aw = iads.ActiveDesktop.AnalysisWindows.Add("Free Space View")
       aw.WindowState =
IadsAutomationLib.IadsWindowStateType.iadsMaximized
       aw.Visible = True

       ' Add an IADS Primitives item and test setting a property
       Dim display As IadsAutomationLib.DataDisplay
       display = aw.DataDisplays.Add("IadsPrimitives.IadsCircle", 0,
0, 100, 100, 0, "circle")
       Dim circle As IADSPRIMITIVESLib.IadsCircle
       circle = display.ControlUnknown
       circle.TranslateX = 100

       ' Add my Cart control and set a property
       display = aw.DataDisplays.Add("ITIP.IADS.MonitorCart", 0, 0,
100, 100, 0, "cart")
       Dim mc As ITIP.IADS.MonitorCart
       mc = display.ControlUnknown

       ' This will crash with Remoting exception
       Try
           Console.WriteLine(mc.PosXfeet)
       Catch ex As Exception
           Console.WriteLine(ex.Message)
       End Try

The only thing I'm doing to make my .NET component assembly work with
COM is to set "Register for COM interop" to true in VS.NET 2003.
Perhaps I'm missing something.

Thanks.

> Hi TW,
>
[quoted text clipped - 22 lines]
> >
> > --TW
Marcus Heege - 12 Jul 2006 15:09 GMT
From your explanations it is not clear where the exception is thrown. The
code that you show seems to be VB6 code, but the exception must be thrown
somewhere in managed code.

Marcus

* w
> This is what I started out assuming. I can successfully add my .NET
> component project reference to my client project and build.
[quoted text clipped - 88 lines]
>> >
>> > --TW
TW - 12 Jul 2006 15:26 GMT
It's actually VB.NET, so it is managed code. Since my main app has all
this code broken into multiple methods, this is a simpler way to test
(and describe) the problem.

The exception is thrown in the statement within the Try/Catch block
when I reference the PosXfeet property of my object, mc.

> From your explanations it is not clear where the exception is thrown. The
> code that you show seems to be VB6 code, but the exception must be thrown
[quoted text clipped - 95 lines]
> >> >
> >> > --TW

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.