2

Does anyone know if it is possible to "Bin deploy" the Async CTP?

Since a large part of Async is basically a compiler trick, I figured that precompiling my application and deploying it to a server without Async CTP installed might work. Unfortunately, it doesn't seem to be this simple. I get the following error message when I try to call an async method:

Task<Result> task = _checker.CheckAsync(input);

The type initializer for 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1' threw an exception.

This is not really the type of error that I would expect, but perhaps there are some replacement assemblies that I could deploy to my Bin directory to fix this? I cannot install the Async CTP on this (production) machine.

Update: I've included the InnerException details as well:

System.MethodAccessException: Attempt by security transparent method 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder1<TResult>..cctor()' to access security critical method 'System.Threading.Tasks.TaskScheduler.add_UnobservedTaskException(System.EventHandler1)' failed. at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1..cctor()

This appears to be a medium trust issue, and not so much an async issue?

1
  • Care to comment on why the question was downvoted?
    – Thorarin
    Jul 10, 2011 at 14:09

1 Answer 1

2

You'll need to deploy AsyncCtpLibrary.dll as well. I would expect that to be all that's required... have you already deployed that alongside your app?

What's the inner exception of the TypeInitializerException?

EDIT: As you say, that looks like a medium trust issue, which wouldn't be addressed by having the whole thing installed anyway. It's probably worth raising this with the team directly (I can do so if you like) in case there's something about your situation which is unusual in terms of the security.

To verify that this is the case, you could try adding a handler for UnobservedTaskException yourself somewhere in your code:

TaskScheduler.UnobservedTaskException += (sender, e) => e.SetObserved();

Do this in a small project which doesn't use async at all - I suspect it'll fail in the same way. If you can tweak your security settings such that that works, the rest may just work from then on.

3
  • AsyncCtpLibrary.dll was deployed automatically. I've added the InnerException details, but it appears to be a medium trust issue :(
    – Thorarin
    Jun 15, 2011 at 6:58
  • I've implemented your verification and tried wrapping in a [SecuritySafeCritical] method as some articles suggested. Things keep failing, so I've sent you an e-mail about getting in contact with the team.
    – Thorarin
    Jun 15, 2011 at 9:11
  • @Thorarin were you successful in this? Mar 4, 2012 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.