Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# and DLL's

C# and DLL's

Scheduled Pinned Locked Moved C#
csharpc++helpquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Ed Hopkins
    wrote on last edited by
    #1

    I am writing a DLL in VC++ that needs to be called by one of our customers who use C#. Unlike my VC++ test application, which statically links the DLL to the EXE and creates the object upon startup, the C# application appears to load the DLL at runtime at the first reference to a DLL call (using the import keyword). THe problem is that subsequent calls to other functions do not work. It seems that there needs to be some pause for the load to happen. Has anyone encountered a similar problem? Ed Hopkins

    N 1 Reply Last reply
    0
    • E Ed Hopkins

      I am writing a DLL in VC++ that needs to be called by one of our customers who use C#. Unlike my VC++ test application, which statically links the DLL to the EXE and creates the object upon startup, the C# application appears to load the DLL at runtime at the first reference to a DLL call (using the import keyword). THe problem is that subsequent calls to other functions do not work. It seems that there needs to be some pause for the load to happen. Has anyone encountered a similar problem? Ed Hopkins

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      Ed Hopkins wrote: THe problem is that subsequent calls to other functions do not work. It seems that there needs to be some pause for the load to happen. Does the first function call always work? Have you tried calling different functions the first time to see if there is a problem? If your dll that you are writing in C++ is based on COM I would hightly recommend you read through information on Runtime Callable Wrappers[^] on MSDN. - Nick Parker
      My Blog | My Articles

      E 1 Reply Last reply
      0
      • N Nick Parker

        Ed Hopkins wrote: THe problem is that subsequent calls to other functions do not work. It seems that there needs to be some pause for the load to happen. Does the first function call always work? Have you tried calling different functions the first time to see if there is a problem? If your dll that you are writing in C++ is based on COM I would hightly recommend you read through information on Runtime Callable Wrappers[^] on MSDN. - Nick Parker
        My Blog | My Articles

        E Offline
        E Offline
        Ed Hopkins
        wrote on last edited by
        #3

        It's not quite that simple ... it works A-OK from the VC++ demo app. It's NOT written in COM just a standard Win32 MFC DLL written in VC++. The timing appears to be due to the finite # of milliseconds it takes for the DLL objects to get created. They are not ready yet, and a subsequent call returns an error since it is pointing to things that are not yet created. Quite strange. Ed

        M 1 Reply Last reply
        0
        • E Ed Hopkins

          It's not quite that simple ... it works A-OK from the VC++ demo app. It's NOT written in COM just a standard Win32 MFC DLL written in VC++. The timing appears to be due to the finite # of milliseconds it takes for the DLL objects to get created. They are not ready yet, and a subsequent call returns an error since it is pointing to things that are not yet created. Quite strange. Ed

          M Offline
          M Offline
          MilesAhead
          wrote on last edited by
          #4

          Hmm, seems to me I've heard MFC doesn't play nice with other frameworks. And .NET is a framework. I've run into some strangeness with MFC. I remember I was experimenting with forms in DLLs and had one done in Delphi that I launched from a VC++ 6.0 MFC app using a worker thread. No matter what I did when I closed the DLL form, I got an exception. However if I displayed a messagebox in the VC++ app after closing the form, I never got an error. I chalked it up to Delphi having a VCL and MFC not being at the root of all the GUI stuff, but who knows? Of course the Delphi DLL form worked fine with every other app I used to launch it, such as Delphi and VB 6.0. Go figure. :)

          E 1 Reply Last reply
          0
          • M MilesAhead

            Hmm, seems to me I've heard MFC doesn't play nice with other frameworks. And .NET is a framework. I've run into some strangeness with MFC. I remember I was experimenting with forms in DLLs and had one done in Delphi that I launched from a VC++ 6.0 MFC app using a worker thread. No matter what I did when I closed the DLL form, I got an exception. However if I displayed a messagebox in the VC++ app after closing the form, I never got an error. I chalked it up to Delphi having a VCL and MFC not being at the root of all the GUI stuff, but who knows? Of course the Delphi DLL form worked fine with every other app I used to launch it, such as Delphi and VB 6.0. Go figure. :)

            E Offline
            E Offline
            Ed Hopkins
            wrote on last edited by
            #5

            Well if implemented correctly MFC is capable of being accessed by other types of compilers ... that in itself is not the issue. The issue is that the way that C# loads DLL's is a bit strange coming from C++ ... I suspect VB does it the same way, I've developed a hacky workaround but it would be nice to know from a real C# expert why this is happening. In fact, forget I even mentioned MFC if you do it with a Win32 (or a Delphi) DLL it will load the same way. I did a little Delphi work myself at one point. Ed

            M 1 Reply Last reply
            0
            • E Ed Hopkins

              Well if implemented correctly MFC is capable of being accessed by other types of compilers ... that in itself is not the issue. The issue is that the way that C# loads DLL's is a bit strange coming from C++ ... I suspect VB does it the same way, I've developed a hacky workaround but it would be nice to know from a real C# expert why this is happening. In fact, forget I even mentioned MFC if you do it with a Win32 (or a Delphi) DLL it will load the same way. I did a little Delphi work myself at one point. Ed

              M Offline
              M Offline
              MilesAhead
              wrote on last edited by
              #6

              Did you try searching knowlegebase for a bug report? You can't be the only one seeing DLL load lag if that's what's happening.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups