Search code examples
wcfworkflow-foundation-4

Updating xamlx-workflow service reference threw XamlObjectWriterException : 'Cannot create unknown type [...]'


In vs 2010, on right clicking and updating the service reference pointing to my xamlx workflow service project, it throws an error (written in raw html) stating that :

XamlObjectWriterException : 'Cannot create unknown type [...]'

[...] pointing out a message variable of my project.

My workflow is xamlx hosted with WorkflowServiceHost class.

It seems to be due to the SendResponse message. Message type uses [DataContract] and [DataMember], and 'Parameters' ha been chosen in the content UI.

Can't find out what exactly is messing in my message type. Maybe it is something in the build properties of my wkf project ...

Any help is very welcome.

Here is the html sent back :


There was an error downloading 'http://localhost:8008/WfDerogationCreation.xamlx'.
There was an error downloading 'http://localhost:8008/WfDerogationCreation.xamlx'.
The request failed with the error message:
--
<html>
    <head>
        <title>'Cannot create unknown type '{http://schemas.microsoft.com/netfx/2009/xaml/activities}Variable({clr-namespace:CompanyName.WorkflowSecurity.Derogation.Messages;assembly=CompanyName.WorkflowSecurity}DerogRequest)'.' Line number '4' and line position '8'.</title>
        <style>
         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
         pre {font-family:"Lucida Console";font-size: .9em}
         .marker {font-weight: bold; color: black;text-decoration: none;}
         .version {color: gray;}
         .error {margin-bottom: 10px;}
         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
        </style>
    </head>
<body bgcolor="white">
            <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>
            <h4> <i>'Cannot create unknown type '{http://schemas.microsoft.com/netfx/2009/xaml/activities}Variable({clr-namespace:CompanyName.WorkflowSecurity.Derogation.Messages;assembly=CompanyName.WorkflowSecurity}DerogRequest)'.' Line number '4' and line position '8'.</i> </h4></span>
            <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
            <b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
            <br><br>
            <b> Exception Details: </b>System.Xaml.XamlObjectWriterException: 'Cannot create unknown type '{http://schemas.microsoft.com/netfx/2009/xaml/activities}Variable({clr-namespace:CompanyName.WorkflowSecurity.Derogation.Messages;assembly=CompanyName.WorkflowSecurity}DerogRequest)'.' Line number '4' and line position '8'.<br><br>
            <b>Source Error:</b> <br><br>
            <table width=100% bgcolor="#ffffcc">
               <tr>
                  <td>
                      <code>
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code>
                  </td>
               </tr>
            </table>
            <br>
            <b>Stack Trace:</b> <br><br>
            <table width=100% bgcolor="#ffffcc">
               <tr>
                  <td>
                      <code><pre>
[XamlObjectWriterException: 'Cannot create unknown type '{http://schemas.microsoft.com/netfx/2009/xaml/activities}Variable({clr-namespace:CompanyName.WorkflowSecurity.Derogation.Messages;assembly=CompanyName.WorkflowSecurity}DerogRequest)'.' Line number '4' and line position '8'.]
   System.Xaml.XamlObjectWriter.WriteStartObject(XamlType xamlType) +1131129
   System.Xaml.XamlWriter.WriteNode(XamlReader reader) +158
   System.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter, Boolean closeWriter) +106
   System.Xaml.XamlServices.Load(XamlReader xamlReader) +56
   System.ServiceModel.Activities.Activation.WorkflowServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +302
   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1461
   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +651

[ServiceActivationException: The service '/WfDerogationCreation.xamlx' cannot be activated due to an exception during compilation.  The exception message is: 'Cannot create unknown type '{http://schemas.microsoft.com/netfx/2009/xaml/activities}Variable({clr-namespace:CompanyName.WorkflowSecurity.Derogation.Messages;assembly=CompanyName.WorkflowSecurity}DerogRequest)'.' Line number '4' and line position '8'..]
   System.Runtime.AsyncResult.End(IAsyncResult result) +688590
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +190
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService) +234
   System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +379
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
</pre></code>
                  </td>
               </tr>
            </table>
            <br>
            <hr width=100% size=1 color=silver>
            <b>Version Information:</b> Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237
            </font>
    </body>
</html>
<!-- 
[XamlObjectWriterException]: 'Cannot create unknown type '{http://schemas.microsoft.com/netfx/2009/xaml/activities}Variable({clr-namespace:CompanyName.WorkflowSecurity.Derogation.Messages;assembly=CompanyName.WorkflowSecurity}DerogRequest)'.' Line number '4' and line position '8'.
   at System.Xaml.XamlObjectWriter.WriteStartObject(XamlType xamlType)
   at System.Xaml.XamlWriter.WriteNode(XamlReader reader)
   at System.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter, Boolean closeWriter)
   at System.Xaml.XamlServices.Load(XamlReader xamlReader)
   at System.ServiceModel.Activities.Activation.WorkflowServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
[ServiceActivationException]: The service '/WfDerogationCreation.xamlx' cannot be activated due to an exception during compilation.  The exception message is: 'Cannot create unknown type '{http://schemas.microsoft.com/netfx/2009/xaml/activities}Variable({clr-namespace:CompanyName.WorkflowSecurity.Derogation.Messages;assembly=CompanyName.WorkflowSecurity}DerogRequest)'.' Line number '4' and line position '8'..
   at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService)
   at System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->## Heading ##
--.
Metadata contains a reference that cannot be resolved: 'http://localhost:8008/WfDerogationCreation.xamlx'.
The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.
If the service is defined in the current solution, try building the solution and adding the service reference again.

Solution

  • I eventually solved this problem like this :

    In the couple of ReceiveResponse / SendReply activities.

    1/ Delete SendReply. 2/ Recreate SendReply by right clicking on the ReceiveResponse activity and reset properties like on the deleted one.

    Xamlx service reference then uploaded quite well ...

    Found that error message was quite inappropriate written in raw html, my screen wasn't big enough to read all of it. Anyway, thank you for your help.