473,395 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Weird behavior with WCF's Binding.BuildChannelFactory()

Hi all,

I'm reading the book Essential WCF and while trying out the code listing at
page 95 I got an ArgumentException when running the code.
Here's the code listing:

BasicHttpBinding binding = new BasicHttpBinding();
BindingParameterCollection parameters = new
BindingParameterCollection();
Message m = Message.CreateMessage(MessageVersion.Soap11,
"urn:sendmessage");

IChannelFactory<IOutputChannelfactory =
binding.BuildChannelFactory<IOutputChannel>(parame ters);

IOutputChannel channel = factory.CreateChannel(new
EndpointAddress("http://localhost/sendmessage/"));
channel.Send(m);
channel.Close();

factory.Close();

I tried to use some other channel types what nothing helped. I got an
exception all the time.
Then I looked at the stack trace and noticed that the exception is thrown
from the method TransactionFlowBindingElement.BuildChannelFactory. I fired up
Reflector and saw that this method internally calls the method
CanBuildChannelFactory of the same class. Inside this method there is this
check:

if ((((typeof(TChannel) != typeof(IOutputChannel)) && (typeof(TChannel) !=
typeof(IDuplexChannel))) && ((typeof(TChannel) != typeof(IRequestChannel)) &&
(typeof(TChannel) != typeof(IOutputSessionChannel)))) && ((typeof(TChannel)
!= typeof(IRequestSessionChannel)) && (typeof(TChannel) !=
typeof(IDuplexSessionChannel))))
{
return false;
}

Does this seem like a valid check? Shouldn't it be using || instead of all
the &&?

Perhaps I'm getting all this wrong and can't figure the code listing from
the book right.

Thanks,
Ben
Sep 11 '08 #1
1 2212
I tried to do some workaround for this.
I created an interface that inherits from all the aforementioned interface
and guess what? It passed that method! But then it failed in some other
method down the codebase that didn't recognise it. Some serious voodoo.
Sep 11 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jonathan Yong | last post by:
I observe a very weird behavior when dynamically create web control and bind events to it. Create a C# ASP.NET application, Put a PlaceHolder and Textbox onto the Web form, and try with the 4...
4
by: =?Utf-8?B?QXJuYXVkIFZpc2N1c2k=?= | last post by:
Hi all, we meet a problem since we use WCF to consume java WebServices. Often the first call works then the second raises the following error : "The underlying connection was closed : " We...
1
by: =?Utf-8?B?aGVyYmVydA==?= | last post by:
Question 1: How do I turn off WCF security to get my apps out the door quickly? Question 2: Where can I find a step by step article/flowchart how to configure WCF security (the WCF books miss this...
2
by: =?Utf-8?B?RGFuaQ==?= | last post by:
Hi, I'm running a little wcf service, regular operations works fine, but when the returned type is a DataTable like this: DataTable GetItems(); (The call reaches the server, it fails...
1
by: lmod | last post by:
I am developing an application using WPF and WCF. This app on the server side will need for WCF services hosted in IIS6 to communicate with WCF services that are hosted as Windows services on the...
0
by: =?Utf-8?B?Q3JhaWdo?= | last post by:
Background: I am currently using WCF for remoting (using CSLA hosted in IIS) with a binding config entry like this: <binding name ="default" transferMode="Buffered" messageEncoding="Text"...
5
by: Max2006 | last post by:
Hi, I am trying to limit my wcf service endpoint to response to only given windows user or group. How can I do that? Is there any way to configure that in the .config file? Thank you, Max
2
by: Steven Cheng | last post by:
Hi Gary, As for the setting you mentioned, it is used to custimze the received data size limitation of WCF binding(such as NetTcpBinding or HttpBinding). After you have definite a customized...
0
by: Jesper Lund Stocholm | last post by:
I have the following requirements: a. Have a WCF-service hosted on IIS (6.0) b. Pass user's AD-credentials to the WCF-service c. NOT use SSL/HTTPS So in IIS I have disabled anonymous access...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.