This question is related to Bug in the dynamic language runtime in combination with IIS 7.5
ChannelFactory
hangs if I provide it with a correctly typed dynamic object.
dynamic src = "MSFT";
var binding = new BasicHttpBinding();
var endpoint = new EndpointAddress("http://www.restfulwebservices.net/wcf/StockQuoteService.svc");
var channel = new ChannelFactory<IStockQuoteService>(binding, endpoint).CreateChannel();
// this will print just fine
Console.WriteLine(channel.GetStockQuote(src as string));
// this will print just fine
Console.WriteLine(new StockQuoteServiceClient().GetStockQuote(src));
// this will never print and the application will hang with no exceptions
Console.WriteLine(channel.GetStockQuote(src));
- The service above is public, is not mine, and you can test this code yourself if you just add the service reference to the endpoint provided in the code;
StockQuoteServiceClient
was created by the Add Service Reference menu item and takes dynamic objects just fine;- This magically doesn't happen when I launch the application with F5 on Debug, all lines print and the program exits correctly;
- If I run it and then attach the debugger during execution I can see it hung on the call to
channel.GetStockQuote(src)
; - If I leave it be, the program eats all my memory;
- It only hangs when I use my own
ChannelFactory
with dynamic objects, as described in the comments.
Why my ChannelFactory
hangs when it takes dynamic objects as parameters when the one created by Add Service Reference runs just fine?