I am trying to convert some vb code to c# but I am stumped. In the following vb code there are no compilation problems because of the way vb is so forgiving about Types.
Dim t As Type, AGNSec As Object
t = Type.GetTypeFromProgID("AGNSecurity.Security")
AGNSec = Activator.CreateInstance(t)
Dim blnValid As Boolean
Member
22 Points
253 Posts
Type error converting VB to C#
Dec 29, 2014 09:52 AM|jjmonty|LINK
I am trying to convert some vb code to c# but I am stumped. In the following vb code there are no compilation problems because of the way vb is so forgiving about Types.
Dim t As Type, AGNSec As Object
t = Type.GetTypeFromProgID("AGNSecurity.Security")
AGNSec = Activator.CreateInstance(t)
Dim blnValid As Boolean
blnValid = AGNSec.VerifyLogin([params omitted])
AGNSec = Nothing
When I convert this code to C# however, I get a compilation error at the AGNSec.VerifyLogin() line.
Type t = null;
object AGNSec = null;
t = Type.GetTypeFromProgID("AGNSecurity.Security");
AGNSec = Activator.CreateInstance(t);
bool blnValid = false;
//errors here in c#:
blnValid = AGNSec.VerifyLogin([params omitted]);
AGNSec = null;
Is there a way of coding this in C# so that it does not error?
Contributor
2132 Points
675 Posts
Re: Type error converting VB to C#
Dec 29, 2014 10:05 AM|David Anton|LINK
Use the 'dynamic' keyword in C#:
http://www.tangiblesoftwaresolutions.com
Instant C# - VB to C# Converter
Instant VB - C# to VB Converter
Member
22 Points
253 Posts
Re: Type error converting VB to C#
Dec 29, 2014 10:16 AM|jjmonty|LINK
God bless you my friend. That worked!