Bug 683223

Summary: Service Reference initialization error in 2.10.1. Works fine in 2.8.1
Product: [Mono] Mono: Class Libraries Reporter: Brian Corbin <bcorbin>
Component: WCFAssignee: Atsushi Enomoto <atsushieno>
Status: CONFIRMED --- QA Contact: Mono Bugs <mono-bugs>
Severity: Major    
Priority: P5 - None Flags: aenomoto: needinfo? (bcorbin)
Version: 2.10.x   
Target Milestone: ---   
Hardware: i686   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: app.config

Description Brian Corbin 2011-03-28 21:13:33 UTC
Created attachment 421773 [details]
app.config

User-Agent:       Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0

When newing up a service client, getting an unhandled exception.

"using (BuildServerSvc.Service1Client jobClient = new BuildServerSvc.Service1Client())" throw an exception in 2.10.1.

BuildServerSvc is a Service Reference generated in Visual Studio.  

This works fine in 2.8.1.  Doesn't work in 2.10.1.


Unhandled Exception: System.ArgumentNullException: Argument cannot be null.
Parameter name: key
  at System.Collections.Generic.Dictionary`2[System.Type,System.ServiceModel.ServiceContractAttribute].ContainsKey (System.Type key) [0x00000] in <filename unknown>:0
  at System.ServiceModel.Description.ContractDescriptionGenerator.GetContractInternal (System.Type givenContractType, System.Type givenServiceType, System.Type serviceTypeForCallback) [0x00000] in <filename unknown>:0
  at System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type givenContractType, System.Type givenServiceType, System.Type serviceTypeForCallback) [0x00000] in <filename unknown>:0
  at System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type givenContractType, System.Type givenServiceType) [0x00000] in <filename unknown>:0
  at System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type contractType) [0x00000] in <filename unknown>:0
  at System.ServiceModel.Description.ContractDescription.GetContract (System.Type contractType) [0x00000] in <filename unknown>:0
  at System.ServiceModel.ChannelFactory.ApplyConfiguration (System.String endpointConfig) [0x00000] in <filename unknown>:0
  at System.ServiceModel.ChannelFactory.InitializeEndpoint (System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] in <filename unknown>:0
  at System.ServiceModel.ChannelFactory`1[BuildServer.BuildServerSvc.IService1]..ctor (System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] in <filename unknown>:0
  at System.ServiceModel.ClientBase`1[BuildServer.BuildServerSvc.IService1].Initialize (System.ServiceModel.InstanceContext instance, System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] in <filename unknown>:0
  at System.ServiceModel.ClientBase`1[BuildServer.BuildServerSvc.IService1]..ctor (System.ServiceModel.InstanceContext instance, System.String endpointConfigurationName) [0x00000] in <filename unknown>:0
  at System.ServiceModel.ClientBase`1[BuildServer.BuildServerSvc.IService1]..ctor (System.ServiceModel.InstanceContext instance) [0x00000] in <filename unknown>:0
  at System.ServiceModel.ClientBase`1[BuildServer.BuildServerSvc.IService1]..ctor () [0x00000] in <filename unknown>:0
  at BuildServer.BuildServerSvc.Service1Client..ctor () [0x00000] in <filename unknown>:0


Reproducible: Always

Steps to Reproduce:
1. Create a simple WCF service with basic contracts.  I used .net/windows for this.
2. Create a separate project and add a service reference to the WCF service via Visual Studio 2010.
3. Call the generated ctor for the Service Client.  IE: using (BuildServerSvc.Service1Client jobClient = new BuildServerSvc.Service1Client())
Actual Results:  
Unhandled Exception: System.ArgumentNullException: Argument cannot be null.
Parameter name: key
  at System.Collections.Generic.Dictionary`2[System.Type,System.ServiceModel.ServiceContractAttribute].ContainsKey (System.Type key) [0x00000] in <filename unknown>:0
  at System.ServiceModel.Description.ContractDescriptionGenerator.GetContractInternal (System.Type givenContractType, System.Type givenServiceType, System.Type serviceTypeForCallback) [0x00000] in <filename unknown>:0
  at System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type givenContractType, System.Type givenServiceType, System.Type serviceTypeForCallback) [0x00000] in <filename unknown>:0
  at System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type givenContractType, System.Type givenServiceType) [0x00000] in <filename unknown>:0
  at System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type contractType) [0x00000] in <filename unknown>:0
  at System.ServiceModel.Description.ContractDescription.GetContract (System.Type contractType) [0x00000] in <filename unknown>:0
  at System.ServiceModel.ChannelFactory.ApplyConfiguration (System.String endpointConfig) [0x00000] in <filename unknown>:0
  at System.ServiceModel.ChannelFactory.InitializeEndpoint (System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] in <filename unknown>:0
  at System.ServiceModel.ChannelFactory`1[BuildServer.BuildServerSvc.IService1]..ctor (System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] in <filename unknown>:0
  at System.ServiceModel.ClientBase`1[BuildServer.BuildServerSvc.IService1].Initialize (System.ServiceModel.InstanceContext instance, System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] in <filename unknown>:0
  at System.ServiceModel.ClientBase`1[BuildServer.BuildServerSvc.IService1]..ctor (System.ServiceModel.InstanceContext instance, System.String endpointConfigurationName) [0x00000] in <filename unknown>:0
  at System.ServiceModel.ClientBase`1[BuildServer.BuildServerSvc.IService1]..ctor (System.ServiceModel.InstanceContext instance) [0x00000] in <filename unknown>:0
  at System.ServiceModel.ClientBase`1[BuildServer.BuildServerSvc.IService1]..ctor () [0x00000] in <filename unknown>:0
  at BuildServer.BuildServerSvc.Service1Client..ctor () [0x00000] in <filename unknown>:0


Expected Results:  
I expect this to not throw an exception, since it worked fine in 2.8.1.  It should create the service client so I can then communicate with the service.

app.config attached

Using Mono 2.10.1 on Centos 5.1.  Built with xbuild on mono 2.10.1.

The reason I upgraded to 2.10.1 is because this exact same statement is leaking memory like a sieve on 2.8.1 and it's wrapped in a using statement.  I even tried calling the GC.collect() immediately after closing the using statement, but still leaked.
Comment 1 Brian Corbin 2011-03-28 21:24:09 UTC
Comment on attachment 421773 [details]
app.config

<?xml version="1.0"?>
<configuration>

  <configSections>
    <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
  </configSections>
  
  <startup>
    <!--<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>-->
  </startup>

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
            useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://pa-app1-dev.wms.com/BuildServerWCF/Service1.svc"
          binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
          contract="BuildServerSvc.IService1" name="BasicHttpBinding_IService1" />
    </client>
  </system.serviceModel>

  <log4net>
    <appender name="FileAppender" type="log4net.Appender.FileAppender">
      <file value="/tmp/log-file.txt" />
      <appendToFile value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
    </appender>
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%ndc] &lt;%property{auth}&gt; - %message%newline" />
      </layout>
    </appender>

    <root>
      <!--<level value="WARN" />-->
      <appender-ref ref="FileAppender" />
      <appender-ref ref="ConsoleAppender" />
      <!-- <appender-ref ref="ADONetAppender_SqlServer" /> -->
      <!-- <appender-ref ref="A" /> -->
    </root>
  </log4net>

  <appSettings>
    <add key="Name" value="TestBuildServer" />
    <add key="Location" value="Chicago"/>
    <add key="LocalSandboxRoot" value="/Sandboxes"/>
    <add key="SandboxTarLocations" value="/mnt/SandboxShare,/mnt/BuildBot"/>
    <add key="LocationToSendSandboxTars" value="/mnt/SandboxShare"/>
    
    <add key="OutputFileDirectory" value="/mnt/BuildServerOutput"/>          
  </appSettings>
</configuration>
Comment 2 Brian Corbin 2011-03-28 21:28:02 UTC
Ignore original attachment: app.config.  The correct config file is listed as a comment.
Comment 3 Forgotten User vxPDddArjq 2011-03-28 23:57:36 UTC
-> class libs.
Comment 4 Atsushi Enomoto 2011-04-01 07:11:55 UTC
Attaching only app.config does not help understanding what you are doing. Please either attach reproducible sources or at least publicly accessible WSDL URL for the client proxy. (Or mail me a private URL for the service, atsushi@ximian.com).