HighTechTalks DotNet Forums  

.NET interface not appearing in COM+ app... help?

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss .NET interface not appearing in COM+ app... help? in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
carl_bevil@yahoo.com
 
Posts: n/a

Default .NET interface not appearing in COM+ app... help? - 08-07-2007 , 02:10 PM






Hi all. I have a .NET component that implements several interfaces
and derives from ServicedComponent. It has a fixed GUID and ProgID.
Everything was working great, and then I implemented a new interface,
IConnectionPointContainer, with this component. Now when I register
it using regsvcs, I get a COM+ application, but the
IConnectionPointContainer interface is missing!

I don't think this is anything related to IConnectionPointContainer,
as I tried creating a simple test interface and got the same results.
Any ideas why interfaces I add don't show up in the COM+ application?

I've tried having the .NET component be installed in the GAC, not
installed in the GAC, changing the order of interface declarations
(getting desperate...), deleting the COM+ application and rebooting
before re-installing.... nothing seems to help. I'm probably missing
something obvious but for the life of me I can't figure it out.

Thanks!

Carl


Reply With Quote
  #2  
Old   
carl_bevil@yahoo.com
 
Posts: n/a

Default Re: .NET interface not appearing in COM+ app... help? - 08-07-2007 , 07:16 PM






Still have no idea on this one, but I've been able to create a simple
example that reproduces the problem. I just created a new C# library
project and added the following class:

------
using System;
using System.Collections.Generic;
using System.Text;
using System.EnterpriseServices;
using System.Runtime.InteropServices.ComTypes;

namespace InterfaceTest
{
public class TestComponent : ServicedComponent,
IConnectionPointContainer
{

#region IConnectionPointContainer Members

void IConnectionPointContainer.EnumConnectionPoints(out
IEnumConnectionPoints ppEnum)
{
ppEnum = null;
}

void IConnectionPointContainer.FindConnectionPoint(ref Guid riid,
out IConnectionPoint ppCP)
{
ppCP = null;
}

#endregion
}
}
------

To the assembly.cs file I added/changed the following properties:

------
[assembly: ComVisible(true)]

[assembly: ApplicationName("TestComponent")]
[assembly: Description("Test component")]
[assembly: ApplicationActivation(ActivationOption.Server)]
[assembly: ApplicationAccessControl(Value = true,
Authentication = AuthenticationOption.Integrity,
ImpersonationLevel = ImpersonationLevelOption.Identify,
AccessChecksLevel =
AccessChecksLevelOption.ApplicationComponent)]
------

I then built the DLL and ran regsvcs on it ("regsvcs
InterfaceTest.dll").

Looking in the COM+ application (through Component Services) I see
that IConnectionPointContainer is *not* listed as one of the
interfaces. Can someone confirm this result? Is this expected? I
need COM-based clients to be able to CoCreate my component using this
interface, and right now they are unable to do so.

Playing around with my original app, I found I could remove and re-add
interfaces that do show up in the COM+ application, and they behave as
expected. I could not get IConnectionPointContainer or a newly created
interface to show no matter what I did.

Carl


Reply With Quote
  #3  
Old   
carl_bevil@yahoo.com
 
Posts: n/a

Default Re: .NET interface not appearing in COM+ app... help? - 08-08-2007 , 01:31 PM



I have a workaround for this and am posting it here so that it might
help someone else. If anyone can explain why this works I'd
appreciate it. My guess is it has to do with the COM visibility of
the assembly that contains the System.Runtime.InteropServices.COMTypes
interfaces (which appear to be the System assembly, which has its
ComVisible attribute set to false).

What I did was manually define the interfaces in my assembly:

[Guid("B196B287-BAB4-101A-B69C-00AA00341D07")]
[InterfaceType(1)]
public interface IEnumConnections
{
void Clone(out IEnumConnections ppenum);
int Next(int celt, CONNECTDATA[] rgelt, IntPtr pceltFetched);
void Reset();
int Skip(int celt);
}

[Guid("B196B286-BAB4-101A-B69C-00AA00341D07")]
[InterfaceType(1)]
public interface IConnectionPoint
{
void Advise(object pUnkSink, out int pdwCookie);
void EnumConnections(out IEnumConnections ppEnum);
void GetConnectionInterface(out Guid pIID);
void GetConnectionPointContainer(out IConnectionPointContainer
ppCPC);
void Unadvise(int dwCookie);
}

[Guid("B196B285-BAB4-101A-B69C-00AA00341D07")]
[InterfaceType(1)]
public interface IEnumConnectionPoints
{
void Clone(out IEnumConnectionPoints ppenum);
int Next(int celt, IConnectionPoint[] rgelt, IntPtr pceltFetched);
void Reset();
int Skip(int celt);
}

[Guid("B196B284-BAB4-101A-B69C-00AA00341D07")]
[InterfaceType(1)]
public interface IConnectionPointContainer
{
void EnumConnectionPoints(out IEnumConnectionPoints ppEnum);
void FindConnectionPoint(ref Guid riid, out IConnectionPoint ppCP);
}

Then IConnectionPointContainer appeared as an interface in the COM+
application.


Reply With Quote
  #4  
Old   
carl_bevil@yahoo.com
 
Posts: n/a

Default Re: .NET interface not appearing in COM+ app... help? - 08-10-2007 , 03:33 PM



This is a really bad solution -- it overwrites the registry entries
for the COM versions of these interfaces and messes things up. Don't
do it. I'm back to the problem of not being able to see this
interface in COM+.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.