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 6640031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:37:31+00:00 2026-05-25T23:37:31+00:00

When an operation invokes an Expression.Call, it will throw an error stating that ‘System.Boolean’

  • 0

When an operation invokes an Expression.Call, it will throw an error stating that ‘System.Boolean’ cannot be converted to ‘System.Void’

More specifically:
I am implementing a ‘wait’ keyword which will simply call WaitOne() on a specified EventWaitHandle, and I am not interested in the return type, as it is supposed to wait indefinitely.

I have tried Expression.Convert(expression, typeof(void)), but it didn’t really do anything interesting.

edit: I found one solution: put the expression in a block. Not sure why it has any effect.

  • 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-25T23:37:32+00:00Added an answer on May 25, 2026 at 11:37 pm

    From the description it sounds like you were trying to create an Expression<Action>.
    However, the WaitOne method has the signature bool WaitOne() thus the resulting expression was trying to return a bool.

    By wrapping the expression in a block you created a small thunk method that has no return value (void).


    E.g. given the following code:

    bool WaitOne() { return true; }
    Action a = WaitOne;
    

    The compiler cannot directly create a delegate of type Action for WaitOne because that would unbalance the stack; ie. the return value from WaitOne needs to be removed from the stack.

    So to help you the compiler silently creates a method, thus what is actually compiled is similar to:

    bool WaitOne() { return true; }
    void k_CompilerGenerated() { WaitOne(); }
    Action a = k_CompilerGenerated;
    

    When building the expression yourself you don’t have the luxury of the compiler doing this for you. So in essence, when you created the block, you manually did this same step that the compiler would normally perform.

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

Sidebar

Related Questions

I need to create a custom Contains LINQ expression that derives from System.Linq.Expressions.Expression that
My operation system is Window XP in Chinese. I'm running flex sdk > asdoc
I have a timely operation that runs on a background thread. While running, I
In C bitwise left shift operation invokes Undefined Behaviour when the left side operand
when a button is clicked it invokes a JavaScript function .. this operation works
I have a WCF service operation that accepts a data contract parameter of custom
I'm trying to learn about Expression trees, and I've created a method that takes
I have a custom domain service with a single [Invoke] operation that returns a
Given a transaction-aware binding with transaction flow enabled and an operation Op1 that has
I have a CXF JAX-WS web service operation named diagnosticPing that accepts two params,

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.