悬赏园豆:50
[已关闭问题]
<P>我在.NET2008下创建了WCF的程序做测试,发现客户端会出现如下错误:</P>
<P>“System.ServiceModel.ClientBase`1”的类型初始值设定项引发异常。</P>
<P>我的代码如下:</P><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->
<DIV class=cnblogs_code><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000"> System;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000"> System.Collections.Generic;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000"> System.Text;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000"> System.ServiceModel;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000"> System.ServiceModel.Channels;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000"> Hello.WCFService.Contract;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">namespace</SPAN><SPAN style="COLOR: #000000"> Hello.WCFService.Client<BR><IMG id=Codehighlighter1_199_935_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_199_935_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_199_935_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_199_935_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_199_935_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_199_935_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_199_935_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_199_935_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_199_935_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_199_935_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> Program<BR><IMG id=Codehighlighter1_223_933_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_223_933_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_223_933_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_223_933_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_223_933_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_223_933_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_223_933_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_223_933_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter1_223_933_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_223_933_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> Main()<BR><IMG id=Codehighlighter1_260_927_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_260_927_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_260_927_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_260_927_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_260_927_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_260_927_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_260_927_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_260_927_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter1_260_927_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_260_927_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_289_680_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_289_680_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_289_680_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_289_680_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_289_680_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_289_680_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_289_680_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_289_680_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter1_289_680_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_289_680_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000"> (Hello.WCFService.Client.HelloClient MyHello </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> Hello.WCFService.Client.HelloClient(</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">Hello_http</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">))<BR><IMG id=Codehighlighter1_431_665_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_431_665_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_431_665_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_431_665_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_431_665_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_431_665_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_431_665_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_431_665_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter1_431_665_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_431_665_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> Console.WriteLine(</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">Begin to invocate the calculator Service</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> Console.WriteLine(</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">Wellcome to WCF World.{0}</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">, MyHello.SayHello(</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">Friend</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">));<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> Console.Read();<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000"> (Exception ex)<BR><IMG id=Codehighlighter1_727_904_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_727_904_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_727_904_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_727_904_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_727_904_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_727_904_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_727_904_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_727_904_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter1_727_904_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_727_904_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> Console.WriteLine(</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">StackTrace:{0}</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">, ex.StackTrace);<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> Console.WriteLine(</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">Message:{0}</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">, ex.Message);<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> Console.Read();<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000"> <BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV>
<DIV class=cnblogs_code><SPAN style="COLOR: #000000">HelloClient.cs的代码如下:</SPAN></DIV>
<DIV class=cnblogs_code><SPAN style="COLOR: #000000"></SPAN> </DIV><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->
<DIV class=cnblogs_code><IMG id=Codehighlighter1_0_65_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_0_65_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_0_65_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_0_65_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_0_65_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_0_65_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_0_65_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_0_65_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN id=Codehighlighter1_0_65_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_0_65_Open_Text><SPAN style="COLOR: #008000">/*</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>using Hello.WCFService.Contract;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>using System.ServiceModel;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #008000">*/</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000"> System;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000"> System.Collections.Generic;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000"> System.Text;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000"> System.ServiceModel;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000"> System.ServiceModel.Channels;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000"> Hello.WCFService.Contract;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">namespace</SPAN><SPAN style="COLOR: #000000"> Hello.WCFService.Client<BR><IMG id=Codehighlighter1_266_797_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_266_797_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_266_797_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_266_797_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_266_797_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_266_797_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_266_797_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_266_797_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_266_797_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_266_797_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> HelloClient : ClientBase</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">IHello</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">, IHello<BR><IMG id=Codehighlighter1_323_795_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_323_795_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_323_795_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_323_795_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_323_795_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_323_795_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_323_795_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_323_795_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter1_323_795_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_323_795_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">internal</SPAN><SPAN style="COLOR: #000000"> HelloClient()<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> : </SPAN><SPAN style="COLOR: #0000ff">base</SPAN><SPAN style="COLOR: #000000">()<BR><IMG id=Codehighlighter1_385_388_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_385_388_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_385_388_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_385_388_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_385_388_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_385_388_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_385_388_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_385_388_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter1_385_388_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_385_388_Open_Text><SPAN style="COLOR: #000000">{ }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> HelloClient(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> endpointConfigurationName)<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> : </SPAN><SPAN style="COLOR: #0000ff">base</SPAN><SPAN style="COLOR: #000000">(endpointConfigurationName)<BR><IMG id=Codehighlighter1_504_507_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_504_507_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_504_507_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_504_507_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_504_507_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_504_507_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_504_507_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_504_507_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter1_504_507_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_504_507_Open_Text><SPAN style="COLOR: #000000">{ }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> HelloClient(Binding binding, EndpointAddress address)<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> : </SPAN><SPAN style="COLOR: #0000ff">base</SPAN><SPAN style="COLOR: #000000">(binding, address)<BR><IMG id=Codehighlighter1_623_626_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_623_626_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_623_626_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_623_626_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_623_626_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_623_626_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_623_626_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_623_626_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter1_623_626_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_623_626_Open_Text><SPAN style="COLOR: #000000">{ }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_635_789_Closed_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_635_789_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_635_789_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_635_789_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top><IMG id=Codehighlighter1_635_789_Open_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_635_789_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_635_789_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_635_789_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top> </SPAN><SPAN id=Codehighlighter1_635_789_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">IHello Members</SPAN><SPAN id=Codehighlighter1_635_789_Open_Text style="DISPLAY: none"><SPAN style="COLOR: #0000ff">#region</SPAN><SPAN style="COLOR: #000000"> IHello Members</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> SayHello(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> Name)<BR><IMG id=Codehighlighter1_711_770_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_711_770_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_711_770_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_711_770_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_711_770_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_711_770_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_711_770_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_711_770_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter1_711_770_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_711_770_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">.Channel.SayHello(Name);<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">#endregion</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV>
<P><SPAN><SPAN style="COLOR: #000000"></SPAN></SPAN> </P>
<P><SPAN><SPAN style="COLOR: #000000">App.config配置文件如下</SPAN></SPAN><SPAN style="COLOR: #000000"></P>
<DIV class=cnblogs_code><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff"><?</SPAN><SPAN style="COLOR: #ff00ff">xml version="1.0" encoding="utf-8" </SPAN><SPAN style="COLOR: #0000ff">?></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">configuration</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">system.ServiceModel</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">Client</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">endpoint </SPAN><SPAN style="COLOR: #ff0000">address</SPAN><SPAN style="COLOR: #0000ff">="http://localhost:8080/HelloService"</SPAN><SPAN style="COLOR: #ff0000"> binding</SPAN><SPAN style="COLOR: #0000ff">="basicHttpBinding"</SPAN><SPAN style="COLOR: #ff0000"> contract</SPAN><SPAN style="COLOR: #0000ff">="Hello.WCFService.Contract.IHello"</SPAN><SPAN style="COLOR: #ff0000"> name</SPAN><SPAN style="COLOR: #0000ff">="Hello_http"</SPAN><SPAN style="COLOR: #0000ff">/></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">Endpoint </SPAN><SPAN style="COLOR: #ff0000">Address</SPAN><SPAN style="COLOR: #0000ff">="http://localhost:8080/HelloService"</SPAN><SPAN style="COLOR: #ff0000"> Binding</SPAN><SPAN style="COLOR: #0000ff">="basicHttpBinding"</SPAN><SPAN style="COLOR: #ff0000"> contract</SPAN><SPAN style="COLOR: #0000ff">="Hello.WCFService.Contract.IHello"</SPAN><SPAN style="COLOR: #ff0000"> name</SPAN><SPAN style="COLOR: #0000ff">="selfHostEndpoint_http"</SPAN><SPAN style="COLOR: #0000ff">/></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff"></</SPAN><SPAN style="COLOR: #800000">Client</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff"></</SPAN><SPAN style="COLOR: #800000">system.ServiceModel</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000"> <BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff"></</SPAN><SPAN style="COLOR: #800000">configuration</SPAN><SPAN style="COLOR: #0000ff">></SPAN></DIV>
<DIV class=cnblogs_code><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></DIV>
<DIV class=cnblogs_code>最奇怪的是我把这些拷贝到我以前用.NET 2005打了SP1的测试例子程序里面却能运行好好的。我以为是Frame版本不一样吧,但是又不能改成Frame 2.0的,改了就不能引用System.ServiceModel了。哎,不知道谁又遇到过这种情况的?我又不知如何上传附件,晕,只好把代码粘贴出来了。</DIV></SPAN>
努力偷懒
|
初学一级
|
园豆:
150
提问于:2008-07-21 23:12