Function Calling a DLL takes too long to process

Hi, i have created a DLL with C#, it calls a Stored Procedure in SQL Server.

I have tested the code in the DLL in an C# Aplication, and works fine, the problem is that i created a function in Excel to call that DLL, the code is like this:

Function SALIDASALMACEN(ByVal subalmacen As String, ByVal depto As String, ByVal familia As String, ByVal datei As String, ByVal datef As String) As Double
Dim myObj
Set myObj = CreateObject("Almacen.Salidas")
SALIDASALMACEN = myObj.salidasinventario(subalmacen, depto, familia, datei, datef)
End Function

It works and get me the desired result, the problem is when i have many cell with the formula, lets say 300. iF i update the formulas (changing de dates for example) Excel start to process the formulas, and when it reachs certain percentaje it slow down and eventually freeze.

I think that the object is created many times, or the DLL is stored in memory too many times, but i'm not sure.

 I tried to add a reference to my DLL but it's not possible, i guees it's because the structure of the DLL.

Any idea on how to solve this problem?

API's are difficult to

API's are difficult to troubleshoot but you might want to start by including a precision timer in your VBA code and measuring the time taken for each value to be returned..