# Soft Declare error. Failed condition : usage count

**URL:** <https://forum.xojo.com/t/soft-declare-error-failed-condition-usage-count/41156>\
**Category:** General\
**Created:** [December 13, 2017, 7:03pm UTC](https://forum.xojo.com/t/soft-declare-error-failed-condition-usage-count/41156 "2017-12-13T19:03:59Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sunil\_Abraham](https://forum.xojo.com/user_avatar/forum.xojo.com/sunil_abraham/32/437_2.png) [@Sunil\_Abraham](https://forum.xojo.com/u/Sunil_Abraham)\
**Post date:** [December 13, 2017, 7:03pm UTC](https://forum.xojo.com/t/soft-declare-error-failed-condition-usage-count/41156/1 "2017-12-13T19:03:59Z")

</div>

I am using soft declare to call a dll in windows. It works perfectly and i keep calling it based on some requirement. All of a sudden after some usage the app crashes with Runtime error. Saying failue condition : usage count. Does anyone can give any clue as what is this error. This dll works perfectly if used with c# language. This error happens at random time while calling the soft declare.

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [December 13, 2017, 8:22pm UTC](https://forum.xojo.com/t/soft-declare-error-failed-condition-usage-count/41156/2 "2017-12-13T20:22:51Z")

</div>

string reference counting may fail if you do something wrong…

---

<div class="post-metadata">

**Author:** ![Sunil\_Abraham](https://forum.xojo.com/user_avatar/forum.xojo.com/sunil_abraham/32/437_2.png) [@Sunil\_Abraham](https://forum.xojo.com/u/Sunil_Abraham)\
**Post date:** [December 14, 2017, 6:24am UTC](https://forum.xojo.com/t/soft-declare-error-failed-condition-usage-count/41156/3 "2017-12-14T06:24:27Z")

</div>

If i do something wrong means it has to fail at the first attempt correct?

I have to call the DLL several times and it works every time and all of a sudden in one of the call the app crashes with Runtime error and this message “Failure condition : usage count”

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [December 14, 2017, 7:28am UTC](https://forum.xojo.com/t/soft-declare-error-failed-condition-usage-count/41156/4 "2017-12-14T07:28:49Z")

</div>

If a variable is affected and it has e.g. reference count of 5 and it’s decremented by error, you would need 5 or 6 times till it fails.

---

<div class="post-metadata">

**Author:** ![Sunil\_Abraham](https://forum.xojo.com/user_avatar/forum.xojo.com/sunil_abraham/32/437_2.png) [@Sunil\_Abraham](https://forum.xojo.com/u/Sunil_Abraham)\
**Post date:** [December 14, 2017, 7:36am UTC](https://forum.xojo.com/t/soft-declare-error-failed-condition-usage-count/41156/5 "2017-12-14T07:36:38Z")

</div>

This error is not happening at a particular interval. Its happening on a random count. Some after 50 calls. Another after 10 calls etc. At the same time same dll is perfectly working with c# and java programming.

---

<div class="post-metadata">

**Author:** ![Maurizio\_Rossi](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/ba8739/32.png) [@Maurizio\_Rossi](https://forum.xojo.com/u/Maurizio_Rossi)\
**Post date:** [December 14, 2017, 8:15am UTC](https://forum.xojo.com/t/soft-declare-error-failed-condition-usage-count/41156/6 "2017-12-14T08:15:12Z")

</div>

It would be helpful if you post here, if possible, your Xojo code.

---

<div class="post-metadata">

**Author:** ![Sunil\_Abraham](https://forum.xojo.com/user_avatar/forum.xojo.com/sunil_abraham/32/437_2.png) [@Sunil\_Abraham](https://forum.xojo.com/u/Sunil_Abraham)\
**Post date:** [December 14, 2017, 9:54am UTC](https://forum.xojo.com/t/soft-declare-error-failed-condition-usage-count/41156/7 "2017-12-14T09:54:14Z")

</div>

Declare Function GLY\_AsyncAutoRepetitiveDeposit Lib “libglorycolx2010.dll” (ByVal h As Integer, p As Ptr, ByRef mRequestID As Integer) As Integer  
Dim ret, mRequestID As Integer

ret = GLY\_AsyncAutoRepetitiveDeposit(mHandle, Addressof CallBackDeposit, mRequestID)

Above is the code and called multiple times. It works perfectly and all of a sudden it crashes.

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [December 14, 2017, 10:26am UTC](https://forum.xojo.com/t/soft-declare-error-failed-condition-usage-count/41156/8 "2017-12-14T10:26:03Z")

</div>

what are parameters of CallBackDeposit?

---

<div class="post-metadata">

**Author:** ![Sunil\_Abraham](https://forum.xojo.com/user_avatar/forum.xojo.com/sunil_abraham/32/437_2.png) [@Sunil\_Abraham](https://forum.xojo.com/u/Sunil_Abraham)\
**Post date:** [December 14, 2017, 10:29am UTC](https://forum.xojo.com/t/soft-declare-error-failed-condition-usage-count/41156/9 "2017-12-14T10:29:35Z")

</div>

Its a method in module and i am getting the callback correctly. The parameter is a structure and i can see the values in structure as well.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 7:01pm UTC](https://forum.xojo.com/t/soft-declare-error-failed-condition-usage-count/41156/10 "2020-10-29T19:01:57Z")

</div>


