CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 1999
    Location
    Leiden, the Netherlands
    Posts
    116

    Wrapping unmanaged C++

    Hello,

    I have a huge set of unmanaged C++ classes, which I wrapped in managed C++.
    Everything is in one assembly.
    Using my wrapper in C# works fine.
    However, when I would like to use the wrapper in managed C++ I get the
    following warnings and errors:

    warning C4945: 'MyType' : cannot import symbol from 'mydll.dll': as
    'MyNamespace::MyType' has already been imported from another assembly
    'mydll.dll'
    stdafx.cpp(0) : see declaration of 'MyNamespace::MyType' first seen type is
    used; re-order imported assemblies to use the current type

    (Is this caused by forward declarations?)

    And:

    error C3635: 'MyUnmanagedNamespace::MyUnmanagedType': undefined native type
    used in 'MyNamespace::MyType'; imported native types must be defined in the
    importing source code
    did you forget to include a header file?

    My questions:

    How can I solve these problems WITHOUT having to include my unmanaged header
    files in the project that uses my assembly? I am not using any unmanaged
    stuff, so why would I like to include anything?
    I want to re-use the code at binary level only.

    Greets,
    Arthur

  2. #2
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: Wrapping unmanaged C++

    How are you trying to reference your dll ?

    Have you tried

    Code:
    #using "name of dll.dll"
    instead of adding it to the references list ?

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  3. #3
    Join Date
    Jun 1999
    Location
    Leiden, the Netherlands
    Posts
    116

    Re: Wrapping unmanaged C++

    I do both...

    The only solution I can think of is to dump all of the header files of my unmanaged library in "uncludeallunmanaged.h", and link the lib of the unmanaged library with my project. I don't want to let the users of this managed dll think about what unmanaged stuff they need to include...

  4. #4
    Join Date
    Dec 2004
    Posts
    1

    Re: Wrapping unmanaged C++

    Doing both is your problem. You need to do only one or the other. If you put the dll in your references and also put a #using statement, it tries to import the dll twice. (it's different than in C#)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured