1
Vote

Add behaviour that fix type load problem when using pure Xoml

description

based on the question posed in the discussion, add a behaviour that fixes the problem of the code being generated that handles the call.
 
Solution is IEndpointBehaviour that binds appdomain typeresolve event and loads the xoml, compiles it and then returns the compiled assembly.
Code should look like this:
Implement the ApplyDispatchBehaviour on an IEndpointBehavior
 
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher)
    {
        AppDomain.CurrentDomain.TypeResolve += new ResolveEventHandler(CurrentDomain_TypeResolve);
    }
 
    System.Reflection.Assembly CurrentDomain_TypeResolve(object sender, ResolveEventArgs args)
    {
        if (args.Name.EndsWith("_wcfimpl"))
        {
            // load and compile Xoml and get the correct type
            WorkflowCompiler wfCompiler = new WorkflowCompiler();
            WorkflowCompilerParameters WfCompilerParams = new WorkflowCompilerParameters();
            WfCompilerParams.GenerateInMemory = true;
            WorkflowCompilerResults wfCompilerResult = wfCompiler.Compile(WfCompilerParams, tempStoredXomlFile);
            // now you should have the assembly compiled, name set in parameters
            return wfCompilerResult.CompiledAssembly;
        }
    }

comments