C++ interface assembly not visible in other .NET projects

I created an interface assembly1 in VC++.net 2005 (debug configuration). By interface assembly I mean just 2 public interface classes within a namespace definition. The interfaces, methods and properties are marked public. Interfaces assembly1 references another interface assembly2 - with the same namespace wrapping its public interface definitons, methods and properties. Build them no problem.

Now I add assembly1.dll as a reference in a VB.net 2005 class library project, and none of the interfaces (or their methods or properties) are visible. Using the Object Browser the dll is listed but cannot be expanded. If I try an Imports on the Namespace from assemby1 or assembly2 .. I get a warning that: [[[Namespace or type specified in the Imports 'EBlah' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases. C:\Documents and Settings\...\Visual Studio 2005\Projects\VBClassLibrary1\VBClassLibrary1\Class1.vb ]]]

Anyone know why this might be

Many Thanks




Answer this question

C++ interface assembly not visible in other .NET projects

  • KUCL

    In C++ this needs to be:

    public: property String^ CorrelationId;

    instead of:

    public property String^ CorrelationId;



  • Peter Gummer

    Doh!

    That was it, I thought that creating an interface only assembly I wouldn't need the corresponding .cpp file (and Jonathan .. that is why it compiled because the header was ignored) .. thanks both!



  • VBnEWb

    Interesting. Reflector does not show the Userdefined namespace (ENET) nor its contents. I neglected to mention that, these assemblies only have the interface definition in them, not any interface implementation, so basically they are just a .h file. Also they have not been registered in the GAC.

    -the first .h file built with /clr as assembly

    // EMOM.h

    #pragma once

    #include "..\EMOM2\EMOM2.h"

    using namespace System;

    namespace ENET {

    public interface class IQueue

    {

    public property String^ Action;

    public property String^ Policy;

    public property String^ Originator;

    public IMessage^ GetMessage(long lngTimeOut );

    public void PutMessage(IMessage^ objMessage);

    public IMessage^ GetBadMessage(long lngTimeOut, IMessage^ objMessage, bool isBad);

    };

    public interface class ISession

    {

    public property String^ OriginatorName;

    public IQueue^ GetQueueFromContext(String^ strContext);

    public IQueue^ GetQueue(String^ strAction, String^ strPolicy);

    public IQueueListener^ GetListener(String^ strAction, String^ strPolicy );

    public void FreeQueue(IQueue^ objQueue);

    public void FreeListener(IQueueListener^ objListener);

    public IQueueDef^ GetQueueDefFromContext(String^ strContext );

    };

    }

    - The 2nd .h file built with /clr as an assembly

    // EMOM2.h

    #pragma once

    using namespace System;

    using namespace System::Runtime::InteropServices;

    namespace ENET {

    [ComVisibleAttribute(true)]

    public interface class IMessage

    {

    public void InitFromBuffer(String^ s);

    public String^ AsBuffer();

    public String^ ClassName();

    public long MessageSize();

    };

    [ComVisibleAttribute(true)]

    public interface class ICallBackObject

    {

    public void CallBack(String^ strContext);

    };

    [ComVisibleAttribute(true)]

    public interface class IQueueListener

    {

    public property Boolean Enable;

    public property ICallBackObject^ CallBackObject;

    public property String^ CallBackObjectName;

    public property String^ UserData;

    };

    [ComVisibleAttribute(true)]

    public interface class IQueueDef

    {

    public property String^ QueueName;

    public String^ AsString();

    public IQueueDef^ InitFromString( String^ strInitString);

    public void Initialize( String^ strServiceName, String^ strTargetServiceName, String^ strPolicy);

    public property String^ Key;

    public property String^ ModuleName;

    public property String^ OriginatorName;

    public property String^ ActionName;

    public property String^ PolicyName;

    public property Boolean NoMsgHeader;

    public property String^ DefaultMsgClassName;

    public property String^ MessageComponentName;

    };

    public interface class IMessageDescriptor

    {

    public property String^ CorrelationId;

    public property Object FLAGS;

    };

    }



  • PierreDSavard

    Note: you can compile a standalone header file - you just need to tell the compiler to treat the header file as a *.cpp file. For example:

    cl /clr /LD /Tp file.h



  • Ananda Ganesh

    This is probably not related but code like:

    public property String^ CorrelationId;

    should not compile.



  • Bill116

    You may want to take a look at the assembly with .Net Reflector. If that doesn't help, can you post the code for us

  • deepak sv

    Shouldn't there be a corresponding cpp file It should have the following contents:

    #include "stdafx.h" // this line may or may not be necessary
    #include "EMOM.h"

    Without a cpp file, the compiler will completely ignore the header.



  • LessXa

    Jonathan, The project (which only contains the .h file above) does compile. But the interfaces are not accessible.

    (aside: why should this not compile and what would you do different )



  • C++ interface assembly not visible in other .NET projects