Showing posts with label newbie. Show all posts
Showing posts with label newbie. Show all posts

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

Monday, March 26, 2012

System.Net.Mail library problems

Hi everyone, I'm newbie on ASP.net and I was trying to to an application to send emails with the following code using System.net.mail namespace:

PrivateSub Envio_Correo(ByVal rutaAsString)'Creando la instancia del mensajeDim correoAsMailMessage = nothing

correo.From =

New MailAddress("b98123839@dotnet.itags.org.usmp.edu.pe")

correo.To.Add(

"amonasiq@dotnet.itags.org.usmp.edu.pe")

correo.Subject =

"Archivo de Confirmación de matricula"

correo.Body =

"Se adjunto archivo de confirmación de matricula de su respectiva facultad"

correo.IsBodyHtml =

False'correo.Attachments.Add(New Attachment(ruta))

correo.Priority = MailPriority.Normal

'Crando la instancia del SMTP clienteDim smtpAsNew SmtpClient

smtp.Host =

"192.168.1.53"Try

smtp.Send(correo)

Catch exAs SmtpException

lMenErr.Text =

"Paso 4: Enviando el correo: " + ex.Message.ToString()

lMenErr.ForeColor = System.Drawing.Color.Red

EndTryEndSub

But always get the same error: Mailbox unavailable. The server response was: Error: Message content rejected

But if i use the namespace system.web.mail with almost the same code:

PrivateSub enviar_correo_antiguo(ByVal rutaAsString,ByVal facuAsString)Dim correoAsNew MailMessageDim adjuntoAsNew MailAttachment(ruta)

correo.From =

"desarrollo@dotnet.itags.org.usmp.edu.pe"

correo.To = Devolver_mail_ora(facu)

correo.Subject =

"Archivo de Confirmación de matricula"

correo.Body =

"Se adjunto archivo de confirmación de matricula de su respectiva facultad"

correo.Attachments.Add(adjunto)

SmtpMail.SmtpServer =

"192.168.1.53"Try

SmtpMail.Send(correo)

Catch exAs Exception

lMenErr.Text =

"Paso 5: Enviando el correo: " + ex.Message.ToString()

lMenErr.ForeColor = System.Drawing.Color.Red

EndTryEndSub

I dont have any problem at all, Could anyone tell me what is wrong in my code?

Sincerly

Kryor

system.web.mail = asp.net version 1.1
system.net.mail= asp.net version 2.0

I know system.web is for framework 1.1 and system.net is for 2.0 but why is working with the old namespace and not with the new one being almost the same code.
each website can only run 1 framework- even if both are installed.
It seems your website is configured to run framework 1.1 ( thats my guess, based on what you posted )
There is a tab in IIS where you set the version for each website.

System.NET is through sockets so you may have to add more code. Try the link below for more about System.NET.Mail. Hope this helps.

http://www.systemnetmail.com/