Discussion:
Using a C# interface in a idl file.
(too old to reply)
rollasoc
2004-01-21 13:37:10 UTC
Permalink
In C#

I have the following in a file in a DLL on its own. Which is registered
from Com Interop


public interface IOpenCloseSomething
{

bool Open();

bool Close();

}

This allows me to create a reference in my C++ DLL and get my class to
implement this interface. This works fine.

However what I actually want to do is in my C++ DLL have an interface
defined that uses IOpenCloseSomething as a parameter in function.

e.g

interface ITestingInterop : IDispatch{

[id(1), helpstring("method SendSomething")] HRESULT
SendSomething([out,retval] IOpenCloseSomething* OpenCloseSomethingObject);

};

The midl compiler complains of undefined symbol IOpenCloseSomething

How can I import my C# dll into my idl.

I've tried using importlib in the library section, but that didn't help my
interface.

Any tips?

Rollasoc
rollasoc
2004-01-21 13:42:33 UTC
Permalink
Eventually I'll need to extend a C# interface in my C++ class if that is at
all possible

If that helps any further.

Rollasoc
Post by rollasoc
In C#
I have the following in a file in a DLL on its own. Which is registered
from Com Interop
public interface IOpenCloseSomething
{
bool Open();
bool Close();
}
This allows me to create a reference in my C++ DLL and get my class to
implement this interface. This works fine.
However what I actually want to do is in my C++ DLL have an interface
defined that uses IOpenCloseSomething as a parameter in function.
e.g
interface ITestingInterop : IDispatch{
[id(1), helpstring("method SendSomething")] HRESULT
SendSomething([out,retval] IOpenCloseSomething*
OpenCloseSomethingObject);
Post by rollasoc
};
The midl compiler complains of undefined symbol IOpenCloseSomething
How can I import my C# dll into my idl.
I've tried using importlib in the library section, but that didn't help my
interface.
Any tips?
Rollasoc
Mattias Sjögren
2004-01-21 20:00:53 UTC
Permalink
Run TlbExp on your assembly to produce a typelib. Then use importlib
in your IDL to import it.



Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
rollasoc
2004-01-22 10:25:48 UTC
Permalink
As I said before I tried using importlib and I get undefined symbol
IOpenCloseSomething

Originally I just set it to register for COM Interop, since this creates the
/tlb for you.
I have tried running TlbExp from the command line and I still get the
undefined symbol error.

Is there anything I should be doing in the interface file? (e.g. any
attributes I should be setting?)

Is there an example on the net I should follow.

Rollasoc
Post by Mattias Sjögren
Run TlbExp on your assembly to produce a typelib. Then use importlib
in your IDL to import it.
Mattias
--
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Christian Fröschlin
2004-01-22 10:53:05 UTC
Permalink
Post by rollasoc
As I said before I tried using importlib and I get undefined symbol
IOpenCloseSomething
Are you using Visual C++ 6.0 or Visual C++ .NET?
Are you creating the C++ class using MFC or ATL?

In case you are using IDL attributes in an ATL project
of Visual C++ .NET, I think this is a bug in the IDL
generation mechanism (such that the importlib in the
generated IDL is located after the declaration of the
interface using the lib).
rollasoc
2004-01-22 10:59:40 UTC
Permalink
Christian,

I'm using Visual C++ .Net and the Class will be IDL.

I did notice that the library section is after the interfaces, so swopped
them over and it made no difference.

Rollasoc
Post by Christian Fröschlin
Post by rollasoc
As I said before I tried using importlib and I get undefined symbol
IOpenCloseSomething
Are you using Visual C++ 6.0 or Visual C++ .NET?
Are you creating the C++ class using MFC or ATL?
In case you are using IDL attributes in an ATL project
of Visual C++ .NET, I think this is a bug in the IDL
generation mechanism (such that the importlib in the
generated IDL is located after the declaration of the
interface using the lib).
Continue reading on narkive:
Loading...