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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:09:46+00:00 2026-05-23T01:09:46+00:00

Please help me with this one, I’ve been writing a console applicaiton using the

  • 0

Please help me with this one, I’ve been writing a console applicaiton using the AsyncCtpLibrary and the C#5 ctp compiler. First time I got to actually running a code which awaits, I got this:

System.BadImageFormatException was unhandled
  Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
  Source=AsyncCtpLibrary
  StackTrace:
    Server stack trace: 
       at [...].<Execute>d__1c.MoveNext()
       at [...].Execute()
       at [...].<Move>d__1d.MoveNext() in[..]:line 266
    Exception rethrown at [0]: 
       at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.<SetException>b__1(Object state)
       at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
       at System.Threading.ThreadPoolWorkQueue.Dispatch()
       at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
  InnerException: 

Am I missing a dll to be referenced?

important new stuff
My failing method looks like this:

public async override Task<bool> Execute()
{
    //do stuff
    await stuff;
    //do other stuff
    await base.Execute()
    //do other stuff
    return true;
}

I’ve followed Jon Skeet’s advice trying to recreate the mistake little by little, and now I can tell that the await base.Execute() line is the killer! If I comment that line out, everything runs, if I leave it in, calling my method fails IMMEDIATELY (not when reaching the base.Execute()). So I assume the ctp compiler does something freaky. Why? What should I never do? How big is the bug?

old stuff:

EDIT:
As for 32bit/64bit issue, my system is 32bit (inside a virtual machine, mind you), and as far as I know AsyncCtpLibrary.dll doesn’t contain unmanaged code. All my projects (class libraries and single console app) all have build tabs like this:screenshot
What can possibly be still wrong?


EDIT:
I also checked the Fusion log viewer, the AsyncCtpLibrary is loaded without any error:

*** Assembly Binder Log Entry  (6/10/2011 @ 9:04:11 PM) ***    
The operation was successful.    
Bind result: hr = 0x0. The operation completed successfully.     
Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll    
Running under executable  C:\Users\Daver\Documents\Visual Studio 2010\Projects\[...]\bin\Debug\MyApp.exe

--- A detailed error log follows. 

=== Pre-bind state information ===    
LOG: User = WIN-N74LV38NLV3\Daver    
LOG: DisplayName = AsyncCtpLibrary, Version=1.0.4107.18181, Culture=neutral, PublicKeyToken=31bf3856ad364e35    
 (Fully-specified)    
LOG: Appbase = file:///C:/Users/Daver/Documents/Visual Studio 2010/Projects/[...]/bin/Debug/

LOG: Initial PrivatePath = NULL    
LOG: Dynamic Base = NULL    
LOG: Cache Base = NULL    
LOG: AppName = MyApp.exe    
Calling assembly : MyLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===

LOG: This bind starts in default load context.    
LOG: Using application configuration file: C:\Users\Daver\Documents\Visual Studio 2010\Projects\[...]\bin\Debug\MyApp.exe.Config    
LOG: Using host configuration file:     
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.    
LOG: Post-policy reference: AsyncCtpLibrary, Version=1.0.4107.18181, Culture=neutral, PublicKeyToken=31bf3856ad364e35    
LOG: GAC Lookup was unsuccessful.    
LOG: Attempting download of new URL file:///C:/Users/Daver/Documents/Visual Studio 2010/Projects/[...]/bin/Debug/AsyncCtpLibrary.DLL.    
LOG: Assembly download was successful. Attempting setup of file: C:\Users\Daver\Documents\Visual Studio 2010\Projects\[...]\bin\Debug\AsyncCtpLibrary.dll    
LOG: Entering run-from-source setup phase.    
LOG: Assembly Name is: AsyncCtpLibrary, Version=1.0.4107.18181, Culture=neutral, PublicKeyToken=31bf3856ad364e35    
LOG: Binding succeeds. Returns assembly from C:\Users\Daver\Documents\Visual Studio 2010\Projects\[...]\bin\Debug\AsyncCtpLibrary.dll.    
LOG: Assembly is loaded in default load context.

I also checked the IL code of the <Execute>d__1c compiler-generated class’ MoveNext() method, and the only assemblies it references ([assemblyName]) are mscorlib, System.Core, and AsyncCtpLibrary.


I checked the manifest of both my dll and AsyncCtpLibrary, mine said .corflags 0x00000003 // ILONLY 32BITREQUIRED, AsyncCtpLibrary said .corflags 0x00000009 // ILONLY, I’m unsure if this can be the problem.

Please help, I’m out of ideas!

  • 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-23T01:09:46+00:00Added an answer on May 23, 2026 at 1:09 am

    EDIT: I’ve heard back from the compiler team, who have confirmed it as a bug. It had already been fixed in their codebase, so hopefully we’ll see that fix in the next release / beta / CTP. The fix isn’t going to be back-ported to “normal” VS2010 as it’s a pretty unusual set of circumstances, at least before async.


    EDIT: Okay, I’ve now got a really short but complete program which demonstrates the problem. I believe it’s a mixture of generics and calling a base method:

    using System;
    using System.Threading.Tasks;
    
    public abstract class AsyncAction<T>
    {
        public virtual Task<T> Execute()
        {
            // We never get this far
            Console.WriteLine("Execute called");
            return null;
        }
    }
    
    public class BoolAction : AsyncAction<bool>
    {
        public async override Task<bool> Execute()
        {
            return await base.Execute();
        }
    }
    
    class Test
    {
        static void Main()
        {
            BoolAction b = new BoolAction();
            b.Execute();
        }
    }
    

    EDIT: Okay, I’ve come up with a workaround. Basically, to call the base class method non-virtually, the compiler creates a synthetic method in BoolAction. It gets that slightly wrong, but we can get it right:

    public class BoolAction : AsyncAction<bool>
    {
        public async override Task<bool> Execute()
        {
            return await BaseExecute();
        }
    
        private Task<bool> BaseExecute()
        {
            return base.Execute();
        }
    }
    

    So whenever you were writing base.Execute, write BaseExecute and insert that extra method. It’s not too bad a workaround, until the team fix the bug.

    EDIT: I’ve simplified the example a bit – you don’t need any overrides, and in particular you don’t need the base class to expose a Task<T>. A call to any virtual base.Foo method will do it:

    public abstract class AsyncAction<T>
    {
        public virtual T GetT()
        {
            return default(T);
        }
    }
    
    public class BoolAction : AsyncAction<bool>
    {
    #pragma warning disable 1998 // We're not awaiting anything
        public async void Execute()
        {
            base.GetT();
        }
    #pragma warning restore 1998
    }
    
    class Test
    {
        static void Main()
        {
            BoolAction b = new BoolAction();
            b.Execute();
        }
    }
    

    EDIT: Contrary to my previous thoughts, this does affect iterators as well. No async CTP required…

    public abstract class Base<T>
    {
        public virtual T GetT()
        {
            return default(T);
        }
    }
    
    public class Derived : Base<bool>
    {
        public System.Collections.IEnumerator Foo()
        {
            base.GetT();
            yield break;
        }
    }
    
    class Test
    {
        static void Main()
        {
            Derived d = new Derived();
            d.Foo().MoveNext();
        }
    }
    

    EDIT: And it affects anonymous functions too…

    using System;
    
    public abstract class Base<T>
    {
        public virtual T GetT()
        {
            return default(T);
        }
    }
    
    public class Derived : Base<bool>
    {
        public void Foo()
        {
            Action x = () => base.GetT();
            x();
        }
    }
    
    class Test
    {
        static void Main()
        {
            Derived d = new Derived();
            d.Foo();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

please help me on this one:) Most of the time I am creating static
Could you please help me with this one: In one of my scripts I
Could all those CORBA experts out there please help me with this one. I
Please help me convert this line to C#. objManagementBaseObject.SetPropertyValue(hDefKey, CType(&H & Hex(RegistryHive.LocalMachine), Long)) Related
Hi Guys could you please help me refactor this so that it is sensibly
Hi Guys can you please help me with this error? What is it? Server
Maybe this cannot be done, but please help or suggest how this can be
I cannot understand how this is possible. Please help!! I have an app with
I know I'm not asking this quite right, either. Please help me better form
I've recently written this with help from SO. Now could someone please tell me

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.