"Managed Debugging Assistant DisconnectedContext" error on async call in unitTest?

1

I'm trying to do this unit test. The register method is a MVC4 method generated by Microsoft. When i'm debugging on the await call I get this error : I'm having the same error for every async call.

[TestMethod]
public async Task TestMethodRegister()
{
    AccountController AccountController = new AccountController();
    IHttpActionResult result = await AccountController.Register(RegisterBinding);
    System.Diagnostics.Debug.WriteLine(result.ToString());
}

Managed Debugging Assistant 'DisconnectedContext' has detected a problem in 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\te.processhost.managed.exe'.

Additional information: Échec de la transition vers le contexte COM 0x7235d8 pour ce RuntimeCallableWrapper avec l'erreur suivante : L’objet invoqué s’est déconnecté de ses clients. (Exception de HRESULT : 0x80010108 (RPC_E_DISCONNECTED)). Cela se produit habituellement car le contexte COM 0x7235d8 dans lequel ce RuntimeCallableWrapper a été créé a été déconnecté ou est occupé à autre chose. Libération des interfaces du contexte COM actuel (contexte COM 0x723468). Cela peut entraîner des dysfonctionnements ou des pertes de données. Pour éviter ce problème, assurez-vous que tous les contextes/cloisonnements/threads COM restent actifs et sont disponibles pour la transition des contextes, tant que l'application n'en a pas terminé avec les RuntimeCallableWrappers qui représentent les composants COM qui s'y trouvent.

c#
asp.net
unit-testing
asynchronous
visual-studio-2015
asked on Stack Overflow Apr 27, 2016 by Frédéric Fect

2 Answers

1

Have you tried adding the following lines to the test cleanup method:

GC.Collect(); GC.WaitForPendingFinalizers();

I had a similar problem and it worked for me:

Managed Debugging Assistant 'DisconnectedContext'

answered on Stack Overflow Jun 13, 2016 by Tom Maher • edited May 23, 2017 by Community
0

My connectionString was not good and i added trycatch to see the error.

answered on Stack Overflow Sep 16, 2016 by Frédéric Fect

User contributions licensed under CC BY-SA 3.0