When I execute my code below, I get these two compile errors, what do I do to remove them?
The type or namespace name 'Task' could not be found (are you missing a directive or an assembly)?
Missing compiler required memeber 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Task'
The return type of an async method must be void, Task or Task<T>
And here is my code, what do I need to do to remedy?
"The return type of an async method must be void, Task or Task<T>"
async Task runfast() // <=== promise to return a Task
{
gc = dogeatdog.runfast(); return ??????????????' // <=== you are NOT returning a Task }
B-) Gerry Lowry, Chief Training Architect, Paradigm Mentors Learning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do it
"The return type of an async method must be void, Task or Task<T>"
async Task runfast() // <=== promise to return a Task
{
gc = dogeatdog.runfast(); return ??????????????' // <=== you are NOT returning a Task }
Hello and thank you for your response. I fully qualified Task and that seems to have removed those compiler errors. I added a return type, but I must not be understanding what it is asking for. In the example above, I want to return the dataset being
stored in gc so I used this syntax:
Since 'runfast()' is an async method that returns 'Task', a return keyword must not be followed by an object expression. Did you intend to return 'Task<T>'?
If you are returning something from your function then it should have a return type like below example. If your gc object is of type int then int, if it is some custom class then the name of the class or anything. More you can read here: https://msdn.microsoft.com/en-us/library/hh191443.aspx
Member
8 Points
22 Posts
Multiple Errors Using <Task>
Mar 07, 2016 06:54 PM|ShowFreeFlying|LINK
When I execute my code below, I get these two compile errors, what do I do to remove them?
The type or namespace name 'Task' could not be found (are you missing a directive or an assembly)?
Missing compiler required memeber 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Task'
The return type of an async method must be void, Task or Task<T>
And here is my code, what do I need to do to remedy?
Star
14297 Points
5797 Posts
Re: Multiple Errors Using <Task>
Mar 07, 2016 07:38 PM|gerrylowry|LINK
@ShowFreeFlyi... welcome to forums.asp.net
try qualifying Task or adding a reference:
"The return type of an async method must be void, Task or Task<T>"
Member
8 Points
22 Posts
Re: Multiple Errors Using <Task>
Mar 07, 2016 07:46 PM|ShowFreeFlying|LINK
Hello and thank you for your response. I fully qualified Task and that seems to have removed those compiler errors. I added a return type, but I must not be understanding what it is asking for. In the example above, I want to return the dataset being stored in gc so I used this syntax:
However, that gives me this compiler error:
Since 'runfast()' is an async method that returns 'Task', a return keyword must not be followed by an object expression. Did you intend to return 'Task<T>'?
Contributor
2400 Points
669 Posts
Re: Multiple Errors Using <Task>
Mar 07, 2016 08:22 PM|PawanPal|LINK
Hi,
If you are returning something from your function then it should have a return type like below example. If your gc object is of type int then int, if it is some custom class then the name of the class or anything. More you can read here: https://msdn.microsoft.com/en-us/library/hh191443.aspx
https://pawanpalblog.wordpress.com
www.jsengineeringworks.com
Member
8 Points
22 Posts
Re: Multiple Errors Using <Task>
Mar 07, 2016 08:37 PM|ShowFreeFlying|LINK
Thank you for that link, it helped me :) -- I altered my code to and that remedied one compiler issue, but now a new one presents itself.
How do I overcome this?
Missing compiler required member 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Task'
Contributor
2400 Points
669 Posts
Re: Multiple Errors Using <Task>
Mar 07, 2016 08:41 PM|PawanPal|LINK
Get reference for using System.Runtime.CompilerServices;
https://pawanpalblog.wordpress.com
www.jsengineeringworks.com