using unmanaged dlls from managed dll wrappers.



Hi,

I hope someone can direct me to the correct newsgroup if this one is
not correct.

I have a unmanaged C++ dll that I need to use from a C# client.  Rather
than use dllImport directly, I created a managed C++ dll (in the same
solution).  In this managed C++ dll, I added a reference (under
references) to the unmanaged dll (it's listed under the project tab).
I also had to #include the header file for the unmanaged dll in my
managed code.

Then I created a C# client (.exe.) in my solution to test this idea.
In the C# client I simply added a reference to the managed C++ dll.
All worked great and I was happy.

Now two weeks later, I would like to use this stuff from a real
project.  From a C# class library (which is used by my C# exe), I call
into my C++ managed dll.  I of course had to add a reference to the C++
managed dll.  Everything compiled.  However, when I run, I get the
following runtime error:

An unhandled exception of type 'System.IO.FileNotFoundException'
occurred in CSharpLibrary.dll.

Additional Information:  File or assembly name ManagedConverterWrapper,
or one of its dependencies, was not found

ManagedConverterWrapper is the managed C++ wrapper I wrote.

I tried adding a reference in my C# class library to the unmanaged C++
dll using the 'Add Reference' tab.  It did not work (got error saying
could not add non DotNet dll) .  Curiously, I was able to add a
reference to the unmanaged dll to my managed C++ dll.  Was that because
it was within same solution or does C++ behave differently with respect
to adding references.

I also tried copying the unmanaged dll everywhere I could think of
(bin/debug of C# class library and C# exe).  No luck!

My questions are:

1.  When one uses a managed C++ dll that in turn makes use of unmanaged
dlls, what else must one do to get things working?  I.e. Compiler
settings, additional references, file copying, etc.

2.  Why did everything work fine when all the project where within one
solution?

Thanks in advance for any pointers, advice or references.

Dave.

.



Relevant Pages

  • Re: using unmanaged dlls from managed dll wrappers.
    ... This is just a DLL mumbob-jumbo!! ... I was surprised when you said you a reference to the unmanaged DLL to your ... But in fact you probably add a PROJECT reference. ... File or assembly name ManagedConverterWrapper, ...
    (microsoft.public.dotnet.framework)
  • Re: using unmanaged dlls from managed dll wrappers.
    ... I'm afraid I still cannot get it to work by copying the dll. ... In the C# project I add a reference to the managed ... I have copied the unmanaged dll to ... File or assembly name ManagedConverterWrapper, ...
    (microsoft.public.dotnet.framework)
  • Re: using unmanaged dlls from managed dll wrappers.
    ... manuall copy the unmanaged DLL in the same directory as your managed ... In the C# project I add a reference to the managed ... ManagedConverterWrapper is the managed C++ wrapper I wrote. ...
    (microsoft.public.dotnet.framework)
  • Re: using unmanaged dlls from managed dll wrappers.
    ... "Add the unmanaged DLL project in your solution and reference it" ... File or assembly name ManagedConverterWrapper, ...
    (microsoft.public.dotnet.framework)
  • VB FAQs (Interview Questions) lot lot
    ... Consider two objects, A and B. A holds a reference to B, ... Why do so many example programs not use the DLL name ... Private Declare Function SendMessage Lib "user32" ... Private Const BUFFER_LENGTH As Long = 255 ...
    (microsoft.public.dotnet.languages.vb)

Loading