Learn how to a build a cloud-first strategyRegister Now


Help with VB.NET to C# conversion.

Posted on 2005-05-04
Medium Priority
Last Modified: 2008-02-07
I'm having problems with this VB.NET to C# conversion:

        Dim UDCPrinter As New UDCWRAPPERLib.Printer
        Dim UDCProfile As UDCWRAPPERLib.Profile

        UDCPrinter.PrinterName = "Universal Document Converter"
        UDCProfile = UDCPrinter.Profile(UDCPrinter.DefaultProfile)

UDCWRAPPERLib.Printer UDCPrinter = new UDCWRAPPERLib.Printer();
  UDCWRAPPERLib.Profile UDCProfile;

  UDCPrinter.PrinterName = "Universal Document Converter";
  UDCProfile = UDCPrinter.get_Profile();

Error is on the last line:
No overload for method 'get_Profile' takes '0' arguments

Object browser tree looks like this:
    Printer (interface)
        IPrinter (interface)

get_Profile(string) is a member of the last node.

I'm using get_Profile because .Profile isn't available in C#.  Why does the above error occur is "string" type is required?

I have tried:
UDCProfile = UDCPrinter.get_Profile(UDCPrinter.DefaultProfile);
and get:
Cannot implicitly convert type 'object' to 'UDCWRAPPERLib.Profile'

Any suggestions?

Question by:brettr
  • 3
  • 3

Accepted Solution

3Mann earned 500 total points
ID: 13932548
try casting:

>I have tried:
>UDCProfile = UDCPrinter.get_Profile(UDCPrinter.DefaultProfile);

UDCProfile = (UDCWRAPPERLib.Profile)UDCPrinter.get_Profile(UDCPrinter.DefaultProfile);

also, just make sure that get_Profile() returns an object compatible to 'UDCWRAPPERLib.Profile'

hope that helps =)

Author Comment

ID: 13932826
Thanks.  That did successfully compile.  I'm just getting error on the default profile name:
Additional information: Cannot receive name of the default profile

I don't have the VB version with me here but I believe the default is actually getting set.  I'll check it tomorrow morning.

How did you know to cast the get_Profile() from the error given?

Expert Comment

ID: 13932855
the message: "Cannot implicitly convert type 'object' to 'UDCWRAPPERLib.Profile'"

it just says that .NET could not automatically convert it to the desired type. so we do manual conversion thus casting :)

good luck
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 13932870
VB.NET seems to do much implied casting vs. C#.  Is that true?
LVL 13

Expert Comment

ID: 13933971
Nope, in VB.NET UDCPrinter.Profile(string) will return UDCWRAPPERLib.Profile object. But in C# get_Profile() just return object, then you must cast to UDCWRAPPERLib.Profile

Following code from 3Mann was right:
UDCProfile = (UDCWRAPPERLib.Profile)UDCPrinter.get_Profile(UDCPrinter.DefaultProfile);

Author Comment

ID: 13933981
Why does C# return only an object and not UDCWRAPPERLib.Profile object?

Expert Comment

ID: 13941773
object is the equivalent of VB's variant

i'm not familiar with UDCWRAPPERLib.  I'm not sure why it returns object.  maybe so you can cast it to compatible types other than UDCWRAPPERLib.Profile.

cheers :)

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month20 days, 23 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question