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

  • Home
  • SEARCH
  • 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 6191973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:51:50+00:00 2026-05-24T02:51:50+00:00

Hi I am trying to call my managed call back callback , from unmanaged

  • 0

Hi I am trying to call my managed call back callback , from unmanaged code thorugh reverse P/Invoke , I am using VS 2003 , and i am not able to complie the following code (in C#). The same code if i copy paste to VS 2005 it compiles without any issues and is executing correctly.

public delegate void MyDelegate();
[DllImport("rtxivsys.dll", CallingConvention=CallingConvention.StdCall)]
static internal extern void SampleDelegate(MyDelegate myDelegate);

public class Myclass
{
   void callthedelegate()
    {
        SampleDelegate(this.Target1);//Compilation error here.
    }
    void Target1()
    {
        //some code here , i want this to be called by the unmanaged code 
}
}

If i don’t give the parenthesis for Target1 , it gives me compilation error that “Target1 is referenced without the parenthesis” and if i give the parenthesis then it says the arguement can’t be converted to MyDelegate.
I am not sure what is making it work in VS2005.
Thanks for any suggestions.

  • 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-24T02:51:52+00:00Added an answer on May 24, 2026 at 2:51 am

    IIRC, the following should work:

    SampleDelegate(new MyDelegate(this.Target1));
    

    The automatic creation of delegates was one of the new features in C# 2.0, first implemented in VS2005.

    NB: I don’t have a working VS2003 nearby, so cannot test this.

    As an aside: if you add paranthesis, like this SampleDelegate(this.Target1()); you are calling Target1 and trying to feed the result to SampleDelegate. But the returned result is not a delegate, hence the compilation error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to call a web service from Excel 2003 module. The way i've
I'm trying to call a native function from a managed assembly. I've done this
I'm trying to learn how to use managed/unmanaged code interop, but I've hit a
I'm trying to call a function in my ActionScript from my JavaScript, I've managed
I am trying to call a webservice using ssl. How do i get the
I'm trying to call a php webservice using WCF. I googled some public php
I've got a p-invoke call to an unmanaged DLL that was failing in my
I am trying to update the Screen on a event Call back in blackberry
I'm trying to call EWS from MonoTouch like in this snippet: byte[] bytes =
When trying to call Close or Dispose on an SqlDataReader i get a timeout

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.