Results 1 to 14 of 14

Thread: [RESOLVED] [2005] Trouble Loading DLL

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    Resolved [RESOLVED] [2005] Trouble Loading DLL

    I have a C++ DLL that was written by a co-worker. My app accesses this DLL fine on my development machine (running VS2005). If I move this app and DLL pair to another machine with 2005 installed everything works but I get an error that the DLL failed to load if I try to run it on a machine that does not have 2005 installed.

    I have already ran the vcredist.exe on the test machine. I am placing the DLL in the same folder as the executable.

    I'm not a work but I will post the actual error message as soon as I get there.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    Re: [2005] Trouble Loading DLL

    Here's the actual error:
    Attached Images Attached Images  

  3. #3
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: [2005] Trouble Loading DLL

    How are you referencing the dll?
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    Re: [2005] Trouble Loading DLL

    using the Add button on the reference tab.
    Attached Images Attached Images  

  5. #5
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: [2005] Trouble Loading DLL

    hmmm, I have never had any lcuk adding C++ dll's like that. I am not saying that it doesn't work, but I have always referenced them like using API's with the System.Runtime.InteropServices namespace. You might want to look into trying it that way using <DllImport etc...
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    Re: [2005] Trouble Loading DLL

    Thanks for the help. I'll look into it but why would my way work on some machines and not others? I haven't proven the VS2005 dependency yet but it sure seems like the exe and dll work on any amchine with 2005 and bombs otherwise.

    I was on my last leg of testing for a July 1st deadline when I ran into this. Oops, looks like things are shifting to the right a little.

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: [2005] Trouble Loading DLL

    after you add the reference.... did it create a file with the dll name and Interop in it? Make sure you send that file along as part of the installation. it's a wrapper that allows the .NET app to talk to the DLL properly. On the development machine it works because, well, the file was created there.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    Re: [2005] Trouble Loading DLL

    did it create a file with the dll name and Interop in it?
    Did it? Shrug shrug.. Where would this file be located?

    On the development machine it works because, well, the file was created there
    It works on machines other than the developement machine as long a that machine has VS2005 installed. I'm soooo confused.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    Re: [2005] Trouble Loading DLL

    I'm trying the method described by bmahler but am having problems. The methods that I'm trying to use are within a class the I usally declare like this:
    Code:
    Private SimIFace As SimIFaceNET
    and use like this
    vb Code:
    1. SimIFace = New SimIFaceNET
    2.     stat = SimIFace.Connect()
    3. If stat = 0 Then
    4.     SimIFace.SetExamMode(1)
    5. End If

    I've deleted the reference from the reference table and added the declarations to my code like this:
    vb Code:
    1. Private Declare Function Connect Lib "OpenSimNET.dll" () As Integer
    2. Private Declare Function SetExamMode Lib "OpenSimNET.dll" (ByVal mode As Integer) As Integer

    or like this

    vb Code:
    1. <DllImport("OpenSimNET.dll")> _
    2.     Public Shared Function Connect() As Integer
    3.     End Function
    4.  
    5.     <DllImport("OpenSimNET.dll")> _
    6.     Public Shared Function SetExamMode(ByVal mode As Integer) As Integer
    7.     End Function

    And I've now make the call like this:
    vb Code:
    1. 'SimIFace = New SimIFaceNET
    2.             'stat = SimIFace.Connect()
    3.             stat = Connect()
    4.             If stat = 0 Then
    5.                 'SimIFace.SetExamMode(0)
    6.                 SetExamMode(0)
    7.             End If

    Everything compiles but when I try to access the Connect method I get an EntryPointNotFound Exception. How would I make an instance of this class using the Declare statements?
    Last edited by campster; Jul 17th, 2007 at 01:43 PM.

  10. #10
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: [2005] Trouble Loading DLL

    Check out this tutorial on codeproject. It is dealing wiht C# but it runs into the same issues you are having and has some good explanations.

    http://www.codeproject.com/csharp/unmanage.asp

    I don't know if you have the ability to modify the cpp dll or not but it looks like the Extern functions need to have a "C" at the beginning to tell the coompiler to not decorate the functions.

    If you can't change the dll you can get the export functions by calling this
    dumpbin -exports path_to_dll

    This will give you the correct export names and then you can set the entrypoint like so
    Code:
        <DllImport("OpenSimNET.dll", EntryPoint:="FUNCTION NAME FROM dumpbin -exports")> _
        Public Shared Function Connect() As Integer
        End Function
    Last edited by bmahler; Jul 17th, 2007 at 03:10 PM.
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    Re: [2005] Trouble Loading DLL

    Unless I'm missing something the DLL is not exporting the functions that I'm looking for. This is a dump that I took about an hour ago. I thought that I was doing something wrong and moved on to something else (which isn't working).
    Attached Images Attached Images  

  12. #12
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: [2005] Trouble Loading DLL

    well it looks like the dll was not made in such a way that it is exporting the functions.

    Perhaps this is another issue.

    This just came to me... Do the machines you are trying to run it on that do not have VS installed have the C runtime dlls? if they are not present then the dll will not work. then one sI can think of off the top of my head are
    msvcr70.dll
    msvcr71.dll
    msvcp70.dll
    msvcp71.dll

    and I am sure that there are more.

    I had an app that used these and I had to include them in the installer because many machines do not already have them.
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    Re: [2005] Trouble Loading DLL

    I'm sure that the machines do not have those DLLs but I ran the VCREDIST.exe file on at least one test machine and the problem is still there. I believe that VCREDIST should install all of the required CRTs.

    http://www.microsoft.com/downloads/d...displaylang=en

    Another interesting thing is that I installed VS2005 on another test machine and the dll won't load there either. There goes the idea that it's based on the installation of VS2005.

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    Re: [2005] Trouble Loading DLL

    You've got to be ^@$%%@% kidding me!!!!

    The problem was the CRT libraries. Evidently you need the vcredist SP1 versus vcredist.

    Here's the link if anyone needs it.

    http://www.microsoft.com/downloads/d...displaylang=en

    Thanks for the help.

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