question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Azure.Data.Tables - CreateTableIfNotExists throws System.NullReferenceException: 'Object reference not set to an instance of an object.'

See original GitHub issue

Hello, I am just writing some sample code to test the Azure.Data.Tables functionality and right away I ran into an exception.

Code is rather simple:

var serviceClient = new TableServiceClient(new Uri("<some uri>"), new TableSharedKeyCredential("<some account name>", "<some key>"));

            string tableName = "TESTDATES";
            TableItem table = serviceClient.CreateTableIfNotExists(tableName);

            var tc = serviceClient.GetTableClient(tableName);

The first iteration, when table does not exists, it runs fine. Subsequent iterations, when table already exists, it throws an excpetion in the CreateTableIfNotExists() line.

Exceptions details: System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=Azure.Core StackTrace: at Azure.Response1.op_Implicit(Response1 response) at ConsoleApp_TestingDatesInAzure.Program.Main(String[] args) in

There is no inner exception.

Thanks Herald

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
christothescommented, Dec 6, 2021

I looked at this again and I realized that the issue is related to the implicit cast for Response<T>. The workaround for this is to either use var for the response type, or explicitly Response<TableItem>

I’ll look into a viable fix for this as well.

related to #25528

0reactions
pakrymcommented, Jan 5, 2022

Can we synthesize an instance of TableItem and return it instead of null? It has only the Name property that we have. The T in Response<T> is defined as non-nullable and multiple customers have hit this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

`Object reference not set to an instance of an ...
Function running the queue trigger after passing message to the queue and getting exception while sending it to the Azure Table within the...
Read more >
Azure.Data.Tables 12.0.0-beta.8 - NullReferenceException ...
Describe the bug NullReferenceException in tableClient. ... NullReferenceException: Object reference not set to an instance of an object. at ...
Read more >
Retrieve records from Azure Table Storage is throwing ...
As a quick look, I think new TableQuery<StringInternTableEntity>() cause the problem because it created new instance all time. Try to move it ...
Read more >
TableServiceAsyncClient (Azure SDK for Java Reference ...
A TableAsyncClient instance for the table in the account with the provided tableName . Throws: IllegalArgumentException - If tableName is null or empty....
Read more >
Is there any overhead of using CreateTableIfNotExists or ...
Azure.WebJobs.Extensions.Storage: Object reference not set to an instance of an object. ... Is there any need of Data Warehouse when using Azure Data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found