brybot

I have a program written in C# and a DLL written in C++. The program works fine on my computer if I place the DLL in the same folder as the executable. I can even change the location of both files and it still works fine on my computer. As soon as I put it on another computer, I get an error saying it cannot locate the DLL. I have tried adding it as a resource which doesnt work, tried putting it in a specific location on the hard drive and so forth but nothing seems to work. The last thing that I tried was adding it as a reference (I hope I dont have references and resources mixed up here) but it wont let me. It says that its not a valid COM or .NET reference or something to that effect. Anyway, I desperately need to get this working on other computers. Any suggestions Thanks

Bryan



Re: Visual C# General cannot find dll

Adamus Turner

My guess is that the directory is not pointing to the .dll correctly.

Are you hardcoding the directory If so, make sure you're placing the .dll in common location ie C:\\mydll.dll otherwise it's going to look for it in C:\\Documents and Settings\Whoever is logged in\mydll.dll and the program won't find it.

Adamus






Re: Visual C# General cannot find dll

brybot

Initially it was not hardcoded, but I tried hardcoding it as well and it still does not work on any other computer.




Re: Visual C# General cannot find dll

Adamus Turner

Is the .dll located on the other computer

Please provide the code with the directory referece.

Adamus






Re: Visual C# General cannot find dll

brybot

I am currently using the following:

[DllImport("botdll2.dll")]
public static extern void init();

I have also tried hardcoding the location to the C: drive. In both cases the DLL has been on the other computer both on the C: drive and in the same folder as the .exe. Neither of these seem to work for the other computer. I have even added it as a reference, but the DLL still needs to be in the same folder for it to run (on the computer it does run on).




Re: Visual C# General cannot find dll

SThotakura2

If you are using MFC/ATL/CRT..

try to copy the dlls under these locations to the directory where your C++ dll resides

C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.ATL
C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRT
C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.MFC


Cheers





Re: Visual C# General cannot find dll

brybot

I chose a win32 application for the C++ dll and I am using a windows application with a single form in C#. I dont believe I am using MFC/ATL/CRT.




Re: Visual C# General cannot find dll

OmegaMan

brybot wrote:
As soon as I put it on another computer, I get an error saying it cannot locate the DLL. I have tried adding it as a resource which doesnt work, tried putting it in a specific location on the hard drive and so forth but nothing seems to work.


It may not be the DLL you are thinking of...it may be a support dll which is not on the target machine. One tool that can eliminate or show which dll is actually missing is called depends.exe. Run it on the target machine and either load your program or the dll in question. It will report any missing support dlls that may not be installed. You can download the tool from here:

Dependency Walker 2.2




Re: Visual C# General cannot find dll

SThotakura2

That means you are using CRT..

Copy all files from the following direcotry to the directory where your dll is residing.

C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRT

cheers





Re: Visual C# General cannot find dll

brybot

I just gave that a try and I am still getting the same error. "Unable to load DLL 'botdll2.dll'.

As for the dependency walker thing, I ran that and there are seemingly hundreds of "dependent" DLLs. Do I need to check their existence manually on the other computers




Re: Visual C# General cannot find dll

OmegaMan

brybot wrote:
I just gave that a try and I am still getting the same error. "Unable to load DLL 'botdll2.dll'.

As for the dependency walker thing, I ran that and there are seemingly hundreds of "dependent" DLLs. Do I need to check their existence manually on the other computers


If there is a dependancy that is not met, then the dll will not work. When you run dependancy walker on the target computer it will identify which support dll is needed, but not there by a nice red icon.





Re: Visual C# General cannot find dll

brybot

Ok I gave that a try on the other computer. At first I got a missing DLL which I added but now I get another error in dependency walker saying "The side by side configuration information for path\botdll2.dll contains errors... the application has failed to start because the application configuration is incorrect." However, the dependency walker works fine on this computer. Any thoughts




Re: Visual C# General cannot find dll

SThotakura2

OK, If it is related to Side by Side (SxS), then this post might help you

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=398802&SiteID=1

Cheers





Re: Visual C# General cannot find dll

brybot

I gave options 2 and 3 a try suggested in that thread. Neither worked. Im running out of ideas... =/
Thanks for all of the help though. Maybe eventually we can figure it out.