0

Can someone help me with this? I tend to work mostly in VB, so this C# compile error is a problem:

// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Threading.Tasks;
using Microsoft.ServiceBus.Messaging;

public static class ServiceBusTaskExtensions
{
    public static Task SendAsync(this TopicClient client, BrokeredMessage message)
    {
        return Task.Factory.FromAsync((cb, state) => client.BeginSend((BrokeredMessage)state, cb, null), client.EndSend, message);
    }
}

A red underline occurs inside the .FromAsync function call and the compile error is; "Cannot convert lambda expression to type 'System.IAsyncResult' because it is not a delegate type".

  • You need to pass the `BeginSend` and `EndSend` methods directly, something like `FromAsync(client.BeginSend, client.EndSend, message, null)`. – Lee Sep 11 '16 at 14:47
  • Thanks! Um...since I don't work in C# much, is there any chance you could expand the code for me? Else I'll be searching the internet for a few hours... – Dominic Whitham Sep 11 '16 at 14:52
  • Actually it looks like `TopicClient` already defines a `SendAsync` method so you don't need this extension method at all. – Lee Sep 11 '16 at 15:02
  • Wow, I think you're right. I excluded the file from my project and all compiles fine, now that this is gone. I've been trying for a week to find a way to use SignalR in my VB Azure Web App using an Azure ServiceBus backplane. I'm hoping that when I compile this new project into a dll, I can access it, set up my configuration (i.e. ServiceBus Endpoint) and be on my way. Thanks for your help. – Dominic Whitham Sep 11 '16 at 15:09
  • I think I've just now realized that the source code that I found is actually the open source behind the actual SignalR .NET code that I need in the first place. In other words, I've already got what I need, now I just need to use it. I had been thinking that I needed to make a dll (from the code I found) to use all this special Azure ServiceBus capability, when really, it was there all along, right? – Dominic Whitham Sep 11 '16 at 15:21
  • The most common way to deal with external dependencies is to use Nuget. If you're using visual studio you can manage nuget packages through the UI or command line. – Lee Sep 11 '16 at 17:37

0 Answers0