Friday, July 2, 2010

WCF Method not found only effects SOAP services

I thought I was going to have to blow the OS away on my laptop since it's the only computer I've got that is experiencing this error with SOAP services (REST works great):

The problem:
Method not found: 'Void System.IdentityModel.Selectors.SecurityTokenRequirement.set_IsOptionalToken(Boolean)'.


Stack trace:
at System.ServiceModel.Security.SecurityProtocol.AddSupportingTokenProviders(SupportingTokenParameters supportingTokenParameters, Boolean isOptional, IList`1 providerSpecList)
at System.ServiceModel.Security.SecurityProtocol.OnOpen(TimeSpan timeout)
at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelFactory`1.ClientSecurityChannel`1.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

The solution:
KB976394 - WCF: Make OutgoingSupportingToken public

Reference:

Friday, January 29, 2010

CF HttpWebRequest does not allow writing to the request stream by default

While trying to send data via a request stream, I ran into this error in the compact framework:
ex = {"Either ContentLength must be set to a non-negative number, or SendChunked set to true in order to perform the write operation when AllowWriteStreamBuffering is disabled."}

This was a bit confusing since I didn't get this error when running from a windows client.  I finally figured out that I have to allow writing to the stream:

private void SendData(WebRequest request, object dto)
{
   // I had to add this for the CF framework. It isn't true by default.
   if (request is HttpWebRequest)
      ((HttpWebRequest) request).AllowWriteStreamBuffering = true;

   using (Stream requestStream = request.GetRequestStream())
   {
         if (IsJsonRequest(request))
            SendDataAsJson(requestStream, dto);
        else SendDataAsXml(requestStream, dto);
   }
}

MSUnit toolbar does not work or is grayed out

If you have a library with MSUnit tests in it (probably because you converted MBUnit or NUnit tests to MSUnit tests) and the MSUnit toolbar will not work (stays grayed out), you are probably missing the ProjectTypeGuids. The line your missing from the library project file in the top most PropertyGroup is this one:


<projecttypeguids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</projecttypeguids>

The line above identifies the project as a test project ({3AC096D0-A1C2-E12C-1390-A8335801FDAB}) in the C# ({FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}) language.


Reference that I found after the fact: