Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

The CancellationTokenSource conflict in Framework 4.0 #90

Open
kevinlai9527 opened this issue May 8, 2019 · 1 comment
Open

The CancellationTokenSource conflict in Framework 4.0 #90

kevinlai9527 opened this issue May 8, 2019 · 1 comment

Comments

@kevinlai9527
Copy link

I created a Framework 4.0 WinForm application, and add OpenNAT by Nuget. And add sample code in Form Load events:

var discoverer = new NatDiscoverer();
var cts = new CancellationTokenSource(10000);
var device = await discoverer.DiscoverDeviceAsync(PortMapper.Upnp, cts);
await device.CreatePortMapAsync(new Mapping(Protocol.Tcp, 1600, 1700, "The mapping name"));

The VS report the following error during compilation.

The type or namespace name 'CancellationTokenSource' could not be found (are you missing a using directive or an assembly reference?)

If I add the reference to System.Threading, it will report another issue:

The type 'CancellationTokenSource' exists in both 'System.Threading, Version=1.0.2856.102, Culture=neutral, PublicKeyToken=31bf3856ad364e35' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

@laurentksh
Copy link

Hello,

This issue has nothing to do with Open.NAT.
However, for those reading this, the fix is to put the following in your usings:
using CancellationTokenSource = System.Threading.CancellationTokenSource;

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants