translate code into c# from vb.net

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

Hello,

I have been trying to convert this vb.net code snippet below into c#
for a couple days and I have had no luck. Maybe someone out there can
point in the right direction.

Dim iPersist As IPersistStreamInit.

iPersist = CType(PDF1.GetOcx, IPersistStreamInit)
iPersist.GetSizeMax(len)

PDF1 is an activex control.


I've tried this below without any luck.
IPersistStreamInit iPersist = (IPersistStreamInit)this.PDF1.GetOcx();
iPersist.GetSizeMax(size);

Thanks All,
 
Try this one, eventhough it looks quite similar to what you already tried.

IPersistStreamInit iPersist;
iPersist = ((IPersistStreamInit)PDF1.GetOcx);
iPersist.GetSizeMax(len);

Yonas
 
The equivalent C# is:

IPersistStreamInit. iPersist;
iPersist = (IPersistStreamInit)(PDF1.GetOcx());
iPersist.GetSizeMax(len);

obtained via our Instant C# VB.NET to C# converter - download the Demo
Edition at http//www.instantcsharp.com

What sort of compiler errors are you getting? A common problem with
accessing COM objects is that the methods may have optional
parameters, which are not optional when accessed from C#.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
Yes, there is that period after IPersistStreamInit that shouldn't be
there - our converter left it in - garbage in garbage out.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
The equivalent C# is:

IPersistStreamInit. iPersist;
iPersist = (IPersistStreamInit)(PDF1.GetOcx());
iPersist.GetSizeMax(len);

obtained via our Instant C# VB.NET to C# converter - download the Demo
Edition at http//www.instantcsharp.com

What sort of compiler errors are you getting? A common problem with
accessing COM objects is that the methods may have optional
parameters, which are not optional when accessed from C#.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*

Hi Dave,

Thanks for the input but "len" seems to always be zero.
iPersist.GetSizeMax(len);

Let me know if you have any suggestions.

Thanks
 
Back
Top