Re: using unmanaged dlls from managed dll wrappers.
Lloyd,
Thanks for the response. I tried copying the unmanaged dll to the
correct directory (manually), and that did not work. I will try the
"Add the unmanaged DLL project in your solution and reference it"
option tomorrow. However, this is not an ideal solution. For
instance, I might want to distribute the unmanaged dll (and the managed
C++ wrapper), without source code.
Dave.
Lloyd Dupont wrote:
> Hi!
>
> This is just a DLL mumbob-jumbo!!
>
> I was surprised when you said you a reference to the unmanaged DLL to your
> managed C++ wrapper.
> But in fact you probably add a PROJECT reference.
>
> Anyway you're right, the problem is that the .NET runtime can't find your
> unmanaged DLL because it's not in the directory.
> To solve that you should either:
> 1. Use a custom build action (project properties) which will copy the dll
> after successfull compilation
> 2. Add the unmanaged DLL project in your solution and reference it.
>
> --
> "drawing in aspnet" <csharpuser@xxxxxxxxxxx> wrote in message
> news:1138826132.728910.313210@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > 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.
... 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) - using unmanaged dlls from managed dll wrappers.
... I hope someone can direct me to the correct newsgroup if this one is ... I have a unmanaged C++ dll that I need to use from a C# client. ... In the C# client I simply added a reference to the managed C++ dll. ... 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: I have a managed DLL code written in C#
... unmanaged DLL code into a managed code. ... DLL code into my own test application I get an error message saying the ... There is no way this code can compile, as dllName doesn't exist in your ... (microsoft.public.dotnet.languages.csharp) - 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) |
|