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. Exporting function from a C# dll with __stdcall calling convention

Exporting function from a C# dll with __stdcall calling convention

Scheduled Pinned Locked Moved C#
csharpquestion
4 Posts 2 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.
  • N Offline
    N Offline
    Nyarlatotep
    wrote on last edited by
    #1

    Hi, I'm a newbie in C#. I want to create a C# dll exporting some functions to be used from a thirdy party application. This application can call functions exported froma DLL but those functions have to be declared as __stdcall. Is there a simple way to export functions froma C# dll as __stdcall (or in a way it works as __stdcall) ? Thanks

    M 1 Reply Last reply
    0
    • N Nyarlatotep

      Hi, I'm a newbie in C#. I want to create a C# dll exporting some functions to be used from a thirdy party application. This application can call functions exported froma DLL but those functions have to be declared as __stdcall. Is there a simple way to export functions froma C# dll as __stdcall (or in a way it works as __stdcall) ? Thanks

      M Offline
      M Offline
      mav northwind
      wrote on last edited by
      #2

      Hi! No, there is no way to export a __stdcall function from a C# assembly, because of several reasons. One of the reasons is that you can't have "functions" outside a class in C#, another one is that all C# methods rely on the CLR interpreting them. You have to create a C++ DLL to do this. Fortunately, you can quite easily access your C# classes from a mixed mode C++ DLL, so it should be possible to create some kind of wrapper to expose a call to a method written in C# for an unmanaged callee.

      Regards, mav -- Black holes are the places where God divided by 0...

      N 1 Reply Last reply
      0
      • M mav northwind

        Hi! No, there is no way to export a __stdcall function from a C# assembly, because of several reasons. One of the reasons is that you can't have "functions" outside a class in C#, another one is that all C# methods rely on the CLR interpreting them. You have to create a C++ DLL to do this. Fortunately, you can quite easily access your C# classes from a mixed mode C++ DLL, so it should be possible to create some kind of wrapper to expose a call to a method written in C# for an unmanaged callee.

        Regards, mav -- Black holes are the places where God divided by 0...

        N Offline
        N Offline
        Nyarlatotep
        wrote on last edited by
        #3

        The method of a wrapper c++ class was the first one I've thought and probably will be the final choice. Anothre question ... If a c# class method is declared as static, is it possible to export it in some way ?+ Thanks for your time

        M 1 Reply Last reply
        0
        • N Nyarlatotep

          The method of a wrapper c++ class was the first one I've thought and probably will be the final choice. Anothre question ... If a c# class method is declared as static, is it possible to export it in some way ?+ Thanks for your time

          M Offline
          M Offline
          mav northwind
          wrote on last edited by
          #4

          Please see this answer[^]

          Regards, mav -- Black holes are the places where God divided by 0...

          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