-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiler.BuildMsi() & async/await #1
Comments
Thank you Alex for such a comprehensive test case. |
Your welcome! :) |
oleg-shilo
pushed a commit
that referenced
this issue
Jun 9, 2017
Using insignia tool for signing the bootstrapper
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!
I got an exception from
Compiler.BuildMsi()
method. I tried to find the reason and it took me a long time. Below I will explain my situation and my solution. I think it will help you to improveWix#
.Compiler.BuildMsi()
builds an installer in separatedAppDomain
. WhenAppDomain
is created.NET
passesCallContext
of the parent domain to the created child domain. It means content of thisCallContext
will be serialized and then deserialized to be transferred it between domains. IfCallContext
contains non-serializable instance any invocation to the childAppDomain
will return an exception. And that exception will not reflect the real problem.Also we can't control content of the
CallContext
because we can use a third party code. So it would be great if we had "clean"CallContext
before creating newAppDomain
. To do this we can useExecutionContext.SuppressFlow()
method which suppresses the flow of the execution context i.e. after callSuppressFlow()
new threads won't get parentCallContext
and will have to use its own "clean"CallContext
. Consequently you can create newAppDomain
within new thread and don't worry aboutCallContext
.After work with child
AppDomain
you must restore the flow of the execution context usingAsyncFlowControl.Undo()
method. TheUndo()
method must be called in the same thread whereSuppressFlow()
method was invoked thus next code waits for completion a thread usingTask.Wait()
and doesn't use await.Unfortunately only this workaround helped me and I can use
Compiler
in anyCallContext
(include async/await code). Probably there is more elegant solution but I think it must be part of your library. :)UPDATE
I've created a little test project which demonstrates my issue and my suggestion.
https://github.com/AlexMAS/WixSharpAsyncTests.git
The text was updated successfully, but these errors were encountered: