# .NET SDK v25.2.0 and 26.0.0 freeze/lock IIS/VS

**URL:** <https://developer.squareup.com/forums/t/net-sdk-v25-2-0-and-26-0-0-freeze-lock-iis-vs/9467>\
**Category:** Questions\
**Created:** [May 15, 2023, 4:50pm UTC](https://developer.squareup.com/forums/t/net-sdk-v25-2-0-and-26-0-0-freeze-lock-iis-vs/9467 "2023-05-15T16:50:40Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![Jordan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/jordan-square/32/1293_2.png) [@Jordan-Square](https://developer.squareup.com/forums/u/Jordan-Square)\
**Post date:** [August 28, 2023, 3:24pm UTC](https://developer.squareup.com/forums/t/net-sdk-v25-2-0-and-26-0-0-freeze-lock-iis-vs/9467/21 "2023-08-28T15:24:54Z")

</div>

@pauld

In regards to the sample application code and why the code is freezing. This is because the DotNet-Framework v4.8 has an issue with the synchronization context that needs an intermediate Task to generate a new context to handle exceptions.

When `wait()` is called on the main thread, the work inside the async function is executed on the same main thread. As a result, there is no available main thread to catch an exception. To address this, you can utilize another task, `Task.Run()` to encapsulate the work. This way, the responsibility will be shifted to the new Task context.

This line can be updated as so, and it should fix the code from freezing up  
`Task.Run(RetrieveLocationsAsync).Wait();`

It’s also important to note that .NET Core does not have a synchronization context, so you won’t encounter this deadlock issue with .NET Core.

Let me know if you have further questions or if that is not working

---

<div class="post-metadata">

**Author:** ![pauld](https://avatars.discourse-cdn.com/v4/letter/p/958977/32.png) [@pauld](https://developer.squareup.com/forums/u/pauld)\
**Post date:** [August 28, 2023, 3:47pm UTC](https://developer.squareup.com/forums/t/net-sdk-v25-2-0-and-26-0-0-freeze-lock-iis-vs/9467/22 "2023-08-28T15:47:25Z")

</div>

Hey @Jordan-Square  
You can replace the call with any method, not just an asynchronous call. No method using the API works with. NET 4.8.  
Is the API only supporting. NET core going forward? Surely the API itself can wrap methods accordingly so the library supports. NET 4.8?

---

<div class="post-metadata">

**Author:** ![dseib](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@dseib](https://developer.squareup.com/forums/u/dseib)\
**Post date:** [December 9, 2023, 12:32am UTC](https://developer.squareup.com/forums/t/net-sdk-v25-2-0-and-26-0-0-freeze-lock-iis-vs/9467/23 "2023-12-09T00:32:54Z")

</div>

It’s been months since I’ve had a chance to look at this after my previous posts in July. I see that @Jordan-Square has blamed .NET 4.8 on the freezing problem and suggested a workaround using a second Task context. My code has no asynchronous component to it at all, so I had to jump through a number of hoops to add some obfuscation to my code. I went from this simple line:

> CreateOrderResponse response = ordersApi.CreateOrder( createOrderRequest );

to this:

> Task responseTask = Task.Run( async () =\> await ordersApi.CreateOrderAsync( createOrderRequest ) );  
> CreateOrderResponse response = responseTask.Result;

The workaround actually works so I’m not complaining too much. Thanks for the explanation - that helped me figure out what I needed to implement.

However, I have to agree with @pauld. How is it that you’ve gone from 25.2.0 to 33.0.0 and the SDK is still broken?

---

<div class="post-metadata">

**Author:** ![Jordan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/jordan-square/32/1293_2.png) [@Jordan-Square](https://developer.squareup.com/forums/u/Jordan-Square)\
**Post date:** [December 20, 2023, 6:17pm UTC](https://developer.squareup.com/forums/t/net-sdk-v25-2-0-and-26-0-0-freeze-lock-iis-vs/9467/24 "2023-12-20T18:17:55Z")

</div>

Hey @dseib @pauld,

I’m glad the work around is currently functioning for you, but I do agree this is unacceptable.

Apologies for the delayed reply, but I have good news! I took this feedback to our SDK team once again, and was able to secure effort towards implementing a fix. I’ve just been informed that we have a fix for this, and I will update this thread when that fix is released.

Thank you for your patience on this, and continually giving feedback! 🙂

EDIT: Expecting the fix will go out some time after the holidays in January

---

<div class="post-metadata">

**Author:** ![pauld](https://avatars.discourse-cdn.com/v4/letter/p/958977/32.png) [@pauld](https://developer.squareup.com/forums/u/pauld)\
**Post date:** [December 21, 2023, 9:40am UTC](https://developer.squareup.com/forums/t/net-sdk-v25-2-0-and-26-0-0-freeze-lock-iis-vs/9467/25 "2023-12-21T09:40:20Z")

</div>

@Jordan-Square that’s great news, thank you! We haven’t been able to update the SDK in a while as we have so many integration points so this will make things much easier for us 🙂

---

<div class="post-metadata">

**Author:** ![Jordan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/jordan-square/32/1293_2.png) [@Jordan-Square](https://developer.squareup.com/forums/u/Jordan-Square)\
**Post date:** [January 19, 2024, 10:54pm UTC](https://developer.squareup.com/forums/t/net-sdk-v25-2-0-and-26-0-0-freeze-lock-iis-vs/9467/26 "2024-01-19T22:54:51Z")

</div>

@pauld @dseib

Happy to let you know that the fix for this issue went out with our latest SDK release yesterday. [More information here](https://developer.squareup.com/docs/sdks/dotnet)

Please consider upgrading to this version of the SDK and let me know if you run into any other troubles!

---

<div class="post-metadata">

**Author:** ![rpenn](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@rpenn](https://developer.squareup.com/forums/u/rpenn)\
**Post date:** [February 21, 2024, 3:31pm UTC](https://developer.squareup.com/forums/t/net-sdk-v25-2-0-and-26-0-0-freeze-lock-iis-vs/9467/27 "2024-02-21T15:31:29Z")

</div>

> [@dseib](#):
>
> However, I have to agree with @pauld. How is it that you’ve gone from 25.2.0 to 33.0.0 and the SDK is still broken?

I know this is going back a couple of months but thanks for getting this updated. I have had to explain to my client that I could not update NuGet Packages for Square for some time. I just tested multiple points in my client’s custom ERP system to make sure everything works with the new SDK update.

Regards,  
Rick

[Previous page](https://developer.squareup.com/forums/t/net-sdk-v25-2-0-and-26-0-0-freeze-lock-iis-vs/9467.md?page=1)
