Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb_dotnet thread: Set property code work in VB 6 but not VB .Net


Message #1 by "Patrick Lam" <lamP@l...> on Wed, 1 May 2002 14:49:08
I tried 

    objIISSMTP.put("IPSecurity", objIPSecurity) 

instead of 

    objIISSMTP.IPSecurity = objIPSecurity

No exception thrown, but it doesn't set the IPSecurity property either!

I also found out the DLL for IPSecurity and Dim objIPSecurity as 
IISOle.IPSecurity, that doesn't solve the problem though!  IIsSmtp appears 
to be defined within SMTPSVC.dll which Object browser can't browse or use!


> However, a similar piece of code in VB .NET does work (note I am not 
using 
t> he Set keyword, in accordance with the VB .NET changes from VB6).  The 
c> ode is:
 >        Dim objIISSMTP
 >        objIISSMTP = GetObject("IIS://machinename/SMTPSVC/1")

>         Dim objIPSecurity

>         objIPSecurity = objIISSMTP.IPSecurity
 >        objIPSecurity.GrantByDefault = False
 >        
 >        Try
 >            ' The following line causes System.ArgumentException to be 
t> hrown
 >            objIISSMTP.IPSecurity = objIPSecurity
 >        Catch ex As Exception
 >            MsgBox(ex.ToString)
 >            Console.WriteLine(ex.ToString)
 >        End Try
 > 
 >        objIISSMTP.setInfo()

> I get the following exception on the line objIISSMTP.IPSecurity = 
o> bjIPSecurity, which my .Net code catches and writes to MsgBox and 
Console 
w> indow:
S> ystem.ArgumentException: The parameter is incorrect.
 >   at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateSet
(> Object o, Type& objType, String name, Object[] args, String[] 
paramnames, 
B> oolean OptimisticSet, CallType UseCallType)
 >   at Microsoft.VisualBasic.CompilerServices.LateBinding.LateSet(Object 
o, 
T> ype objType, String name, Object[] args, String[] paramnames)
 >   at SMTPApiTest.Form1.cmdGetObj_Click(Object sender, EventArgs e) in 
C> :\dev\SMTPApiTest\Form1.vb:line 132
 > 
W> hat is wrong with my .Net code?

  Return to Index