[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

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

carl_bevil

8/7/2007 6:10:00 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

3 Answers

carl_bevil

8/7/2007 11:17:00 PM

0

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

carl_bevil

8/8/2007 5:31:00 PM

0

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.

carl_bevil

8/10/2007 7:34:00 PM

0

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+.