microsoft / CSharpClient-for-Kafka

.Net implementation of the Apache Kafka Protocol that provides basic functionality through Producer/Consumer classes. The project also offers balanced consumer implementation.
Other
463 stars 95 forks source link

ZooKeeper can't load log4net assembly #54

Closed Neftedollar closed 8 years ago

Neftedollar commented 8 years ago
var consumerConfig = ConsumerConfiguration.Configure("consumer");
var zkConsConnector = new ZookeeperConsumerConnector(consumerConfig, true); //exceptionThrownHere

Exception message:

ZookeeperConsumerConnector exception: Exception Message: Unable to connect to SERVERSTRINGS Source: KafkaNET.Library Stack Trace: в Kafka.Client.ZooKeeperIntegration.ZooKeeperConnection.Connect(IWatcher watcher) в Kafka.Client.ZooKeeperIntegration.ZooKeeperClient.Connect() в Kafka.Client.Consumers.ZookeeperConsumerConnector.ConnectZk() в Kafka.Client.Consumers.ZookeeperConsumerConnector..ctor(ConsumerConfiguration config, Boolean enableFetcher, EventHandler rebalanceHandler, EventHandler zkDisconnectedHandler, EventHandler zkExpiredHandler)

---- Inner Exception ---- Exception Message: Could not load file or assembly "log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=1b44e1d426115821" or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Source: ZooKeeperNet Stack Trace: в ZooKeeperNet.ZooKeeper..ctor(String connectstring, TimeSpan sessionTimeout, IWatcher watcher) в Kafka.Client.ZooKeeperIntegration.ZooKeeperConnection.Connect(IWatcher watcher)

---- Inner Exception ---- Exception Message: Could not load file or assembly "log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821" or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Source: Stack Trace:

App.config:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="log4net" publicKeyToken="1b44e1d426115821" culture="neutral" />
      </dependentAssembly>
        <bindingRedirect oldVersion="0.0.0.0-1.2.10.0" newVersion="1.2.15.0"/>
    </assemblyBinding>
  </runtime>

Please tell me how Can I fix it? And why should we use log4net instead of ILog interface?

mhorstma commented 8 years ago

Unfortunately, I discovered this issue after making the upgrade. The problem is that log4net decided to change their public key token after version 1.2.10.0, so standard binding redirects don't work. There is discussion of this exact issue on stackoverflow (http://stackoverflow.com/questions/3158928/referencing-2-different-versions-of-log4net-in-the-same-solution) and we'll have to decide how to work around this painful break by either removing the log4net dependency and/or implementing some kind of workaround. I suspect the right thing to start with for now is to undo the log4net upgrade and go back to using 1.2.10 as ZooKeeper.Net requires.

Neftedollar commented 8 years ago

@mhorstma thank u. It's realy helpfull.