Use unmanaged dll

  • Thread starter Thread starter Aleksey
  • Start date Start date
A

Aleksey

Hi All!

I have a following problem:

We have a unmanaged dll wrote in C. In this dll we have 2 classes: class Foo
and class Foo_Impl that inherited from Foo. Foo class was created to be
exported from dll, like interface. So, there is a function in the dll,
something like that:

Foo *STDCALL create_foo() {return (new Foo_Impl);}

Now I have a managed code in C# that need use this dll. I made my wrap
managed dll, where I call functions of Foo by entry points, but in spite of
creation Foo_Impl in unmanaged dll, my calls of it's methods arrive into Foo
class!!!

Did anybody solve problem like this? What should I do?
I may change unmanaged dll to export functions by AnsiC. But is is a lot
of changes. It should be another way.

Thanks a lot
 
Aleksey said:
Hi All!

I have a following problem:

We have a unmanaged dll wrote in C. In this dll we have 2 classes: class
Foo
and class Foo_Impl that inherited from Foo. Foo class was created to be
exported from dll, like interface. So, there is a function in the dll,
something like that:

Foo *STDCALL create_foo() {return (new Foo_Impl);}

Now I have a managed code in C# that need use this dll. I made my wrap
managed dll, where I call functions of Foo by entry points, but in spite
of
creation Foo_Impl in unmanaged dll, my calls of it's methods arrive into
Foo
class!!!

Did anybody solve problem like this? What should I do?
I may change unmanaged dll to export functions by AnsiC. But is is a lot
of changes. It should be another way.

Thanks a lot

Quite normal, create_foo returns Foo_Impl as a Foo type pointer, if this is
intended, you'll need to cast.....

Foo *ptr = create_foo();
static_cast<Foo_Impl*>(ptr)->Function(...);

Willy.
PS. Note that this is a C# NG, your question is more likely a C++ question,
so you might better post to the VC NG - >
microsoft.public.dotnet.languages.vc

Willy.
 
Back
Top