Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3999288
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:38:17+00:00 2026-05-20T07:38:17+00:00

I have had this problem with C# when I was using DotNet1.1 The problem

  • 0

I have had this problem with C# when I was using DotNet1.1

The problem is this. I have an unmanaged dll, which has a function which takes a function pointer (among other arguments). When I declare the DLLImport in C# code, I pass a delegate. But the delegates in C# have stdcall calling convention whereas the unmanaged function expects a cdecl function pointer. Thus my naive approach resulted in crashes. Then I found the following: http://www.codeproject.com/KB/cs/cdeclcallback.aspx Some guy wrote an excellent library that enables changing calling convention of the delegate by, as I understood, MSIL-hacking. Things went well, until…

I migrated to VS2008 and the new version of .NET. Under this version the abovementioned library doesn’t work. I am not really a C# or .NET expert, and, to tell the truth, I barely understand what his library does (although it’s open-source), so I don’t even want to try to adapt it to new .NET. However I am hoping that newer version of C# has some better solution available for my problem.

So, SO experts, please help me with my pain in the buttocks 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:38:18+00:00Added an answer on May 20, 2026 at 7:38 am

    By default the p/invoke system wraps your delegate in a stdcall function. You can change the generated wrapper’s calling convention by using the UnmanagedFunctionPointer attribute:

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate void MyDelegate();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The responses I've got to this question have solved the problem I had in
This probably has a simple answer, but I must not have had enough coffee
currently using jq 1.4.2 And i have gone through this forum and other forums
I have had to do this several times, usually when trying to find in
We have/had a phantom delay in our app. This was traced to the initialisation
Now I have seen this question in another forum but it didn't had an
This question is all over SO, but no one seems to have had the
Have had to write my first proper multithreaded coded recently, and realised just how
We have had SharePoint where I work for a little while now, but we've
I have had a bug recently that only manifested itself when the library was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.