Saturday, March 31, 2012

System.InvalidCastException: Error de QueryInterface para la interfaz GrosConexion._ClaFun

Hi,
I'km newbie in asp.net. My problem is the subject of this post 'System.InvalidCastException: Error de QueryInterface para la interfaz GrosConexion._ClaFunciones'
I have a dll from a software provider, and i must use your functions from an asp page. My code is (in Page_Load Event of a webform)

Dim RPSGrosVariablesAs GrosVariablesGenererales.ClaVariables

RPSGrosVariables =New GrosVariablesGenererales.ClaVariables

Dim RPSGrosConexionAs GrosConexion.ClaFunciones

RPSGrosConexion =New GrosConexion.ClaFunciones

IfNot IsPostBackThen

gblRutaINI = System.Web.HttpRuntime.AppDomainAppPath & "Prueba.INI"

TextBox1.Text = gblRutaINI

If RPSGrosConexion.AbrirConexion(gblRutaINI, gblMensajeRPS) < 0Then

'Connection fails

Else

'Connection to database ok

EndIf

EndIf


The function AbrirConexion connects to a SQL Server database and returns a short.
If short is less than 0 the connection is OK
I have read very posts in a lot of forums, but my problem is not resolved.
Anyone cab help me? Sorry from my English
Many, many thanx

Guessing of course - without knowing what's in the functions etc.., but try changing this line
If RPSGrosConexion.AbrirConexion(gblRutaINI, gblMensajeRPS) < 0Then
to
If RPSGrosConexion.AbrirConexion(textbox1.text, gblMensajeRPS) < 0Then
Also , I would use a try block - something like...
Try
Dim MyShort as Short
MyShort =RPSGrosConexion.AbrirConexion(textbox1.text, gblMensajeRPS)
'do other stuff here with open connection - I'm guessing
Catch exc as exception
Finally
'close connection- if the AbrirConexion leaves it open- I don't know
End Try
HTH


Today, when I turn on my computer, the first time I try the code (without your modification), it runs ok. But the next times i have the same error.
The function AbrirConexion open the connection but don't close it.
And I don't know how to close a connection open by a function.
I don't understand it
Help me, please
Well , we can't guess at it...
check out the Reflector tool here ...http://www.aisto.com/roeder/dotnet/
this will aloow you to "see" inside the DLL - it's methods etc..
use that to read through what functions / methods are available. Youwill run the program and tell it to open the DLL for the component yourare trying to use.
Also, can you get support from the authors of this DLL ?
Hope That Helps

OK, I'll try it
Many thanx

0 comments:

Post a Comment