Closed aistosi closed 8 years ago
Forgive me, my VB.Net is a little rusty, but aren't you simply missing one or more Imports?
System.Reactive.Linq is one of the imports. https://msdn.microsoft.com/en-us/library/hh211607(v=vs.103).aspx
For some reason I also do not get Intellisense on any of the NEventSocket objects that I create.
That sounds more like a Visual Studio config/environment issue than a lib issue.
Re: namespaces - they're at the top of each example in the ReadMe :)
Dan, I ran the same code in C# and it didn't have this issue. It appears that there might be incompatability with VB.NET, or like you said, something not configured correctly in VB env. Are you aware of any issues that NEventSocket would have with VB?
Probably just gonna create a dll in C# and link up to my vb win service.
Apart from the syntax there's no (significant) difference in VB.Net vs C#; it both compiles to the same CIL. So, yes, you can compile the C# code to a DLL and reference that. You can also simply include the C# code in your project (you can mix C#/VB.Net (and any other .Net languages for that matter) in a single project (or solution)). But in the end simply using the correct imports etc. should work for VB.Net just as well as it does for C#. I'm 99% sure it's PEBKAC. You could post the code entirely (note: minimal testcase preferred over hundreds of lines of code!) so we can easily reproduce your problem and point out any missing imports / mistakes you made.
No problems with VB intellisense in VS2015 here..
Ok I give up. I just created a sample class library project and copied the code on the front page and getting two errors.
using System;
using System.Reactive.Linq;
using System.Threading.Tasks;
using NEventSocket;
using NEventSocket.FreeSwitch;
namespace NEventPSELib
{
public class NEventPSELib
{
public async Task Test()
{
using (var socket = await InboundSocket.Connect("localhost", 8021, "ClueCon"))
{
var apiResponse = await socket.SendApi("status");
Console.WriteLine(apiResponse.BodyText);
//Tell FreeSwitch which events we are interested in
await socket.SubscribeEvents(EventName.ChannelAnswer);
//Handle events as they come in using Rx
socket.Events.Where(x => x.EventName == EventName.ChannelAnswer)
.Subscribe(async x =>
{
Console.WriteLine("Channel Answer Event " + x.UUID);
//we have a channel id, now we can control it
await socket.Play(x.UUID, "misc/8000/misc-freeswitch_is_state_of_the_art.wav");
});
Console.WriteLine("Press [Enter] to exit.");
Console.ReadLine();
}
}
}
}
'Observable.Where
And
Cannot convert lambda expression to type 'IObserver
What the hell am I missing?
What version of .Net are you trying to use? (Right click project -> Properties -> Application) - you can paste a screenshot straight into the textbox and github will upload it for you.
This is the original VB project. Unfortunately I will not be able to create a C# dll at a time, since it requires a lot of rewriting. You can also see the error at the bottom of the screenshot.
I am getting intellisense when I specified the type for the connection socket. Looks like Dim
I'd start with correcting / fixing the NuGet package version; the warning in your screenshot is pretty clear and also tells you how to fix it (or at least where to get more information on how to fix it).
Looks like Dim and var are not exactly the same in these languages.
Omitting the type in VB.NET (VB9) will implicitly type the variable.
This is not the same as "option strict off" in previous versions of VB.NET, as the variable is strongly-typed, it's just done so implicitly (like the C#
var
) keyword.Dim foo = "foo"
foo
is declared as aString
.Option Infer must be on in order for this to function properly
Ah yeah that NuGet error looks like the smoking gun! Well spotted.
So I went in and manually cleaned out all the references to Reactive Extenstions and NEventSocket in the project file, cleaned out packages.config, as well as packages folder. Reinstalled NEventSocket, still no 'Where' function. Installed the latest System.Reactive.Linq and voila, error is gone and can get past it in runtime as well. Does current NEventSocket have an outdated dependency for Reactive Extensions?
NEventSocket internalizes ReactiveExtensions, exposing only IObservable<T>
on the public API which is in the System
base class namespace. This means we'll never conflict with whatever version of RX you may be using in your app.
I see. Thank you for the help. Both of you.
Hello,
I am trying to use this library for the windows service project at my work, but getting the following error: Public member 'Where' on type 'Select(Of BasicMessage,EventMessage)' not found.
I am using an example for the Inbound Socket Client from the main page. The code looks like this:
goSocket is a global object. The error happens where it subscribes to events. Am I missing something? I tried in .NET 4.5 and 4.6.1. I got the latest version of System.Reactive.Linq. Can't figure it out.