NullReferenceException in closure
See original GitHub issueWhat You Are Seeing?
A NullReferenceException
.
What is Expected?
this != null
What version of Cake are you using?
0.17.0
Are you running on a 32 or 64 bit system?
64 bit
What environment are you running on? Windows? Linux? Mac?
Windows
Are you running on a CI Server? If so, which one?
No.
How Did You Get This To Happen? (Steps to Reproduce)
[Edit: The code below is incorrect. See this comment for the correction.]
string mytext = "hello";
Action myaction;
// local block
{
myaction = () =>
{
var t = mytext; // NullReferenceException
}
}
myaction();
A NullReferenceException
is thrown since this
captured in the closure is null
for some reason.
Issue Analytics
- State:
- Created 7 years ago
- Comments:19 (10 by maintainers)
Top Results From Across the Web
NullReferenceException on closing datareader
Close () an exception that says NullRefferenceException. What am I doing wrong? EDIT. I just noticed that reader = cmd.ExecuteReader(); throws an ...
Read more >How to solve this problem: RemoteException wrapping ...
NullReferenceException: Object reference not set to an instance of an object. at lambda_method(Closure , ActivityContext ) at Microsoft.
Read more >How can I fix the error: System.NullReferenceException
A NullReferenceException exception is thrown when you try to access a member on a type whose value is null. A NullReferenceException exception ...
Read more >Null reference exception in the close function - Dispose ...
I am using dispose pattern to clear Postgresql resources. Occasionally following exception is thrown. Do you have ideas what can cause this ...
Read more >NullReferenceException when close connection #2143
Exception message: Object reference not set to an instance of an object. Stack trace: at Npgsql.NpgsqlConnection.Close(Boolean wasBroken) at ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@patriksvensson: Seems there is a similar bug in Roslyn: https://github.com/dotnet/roslyn/issues/16895
Should I file a new issue there?
@peter-perot @wozzo this is now sorted without need for experimental as we unified around a newer version of Roslyn since 0.22.0.