C# 2008 invoking VB6 objects?

G

gregarican

Okay, long story I'll try to make short. Our company has a legacy VB6
app running on Citrix. There apparently is some quirkiness in how it
handles the Printers collection for the logged on Citrix user. I don't
have the source code for the legacy VB6 app but am trying to push the
issue with their tech support group. I can tell that native Windows
printer lists for the Citrix session are correct. Through running WSH
scripts, launching a published Citrix Windows Printer folder window,
etc. It's just how the VB6 app handles iterating the printer list
that's the culprit.

To further prove my point I'd like to launch a custom app that lists
the printers in like manner that the MSVBVM60.DLL handles things. I
don't have Visual Basic 6.0 development tools, however. But I do have
Visual Studio 2005 as well as 2008. Here lies my question. Can I add a
reference to Interop.VBA or something in order to iterate the printers
in VB6 manner? When I add that Interop.VBA reference all I see is a
generic Collection object but no sign of the Printer object, the
Printers collection, etc.
 
J

Jason Keats

gregarican said:
Okay, long story I'll try to make short. Our company has a legacy VB6
app running on Citrix. There apparently is some quirkiness in how it
handles the Printers collection for the logged on Citrix user. I don't
have the source code for the legacy VB6 app but am trying to push the
issue with their tech support group. I can tell that native Windows
printer lists for the Citrix session are correct. Through running WSH
scripts, launching a published Citrix Windows Printer folder window,
etc. It's just how the VB6 app handles iterating the printer list
that's the culprit.

To further prove my point I'd like to launch a custom app that lists
the printers in like manner that the MSVBVM60.DLL handles things. I
don't have Visual Basic 6.0 development tools, however. But I do have
Visual Studio 2005 as well as 2008. Here lies my question. Can I add a
reference to Interop.VBA or something in order to iterate the printers
in VB6 manner? When I add that Interop.VBA reference all I see is a
generic Collection object but no sign of the Printer object, the
Printers collection, etc.

// Reference: Microsoft.VisualBasic.PowerPacks.Vs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
EnumeratePrintersCollections();

Console.WriteLine();
Console.Write("Press any key to continue...");
Console.ReadKey();
}

public static void EnumeratePrintersCollections()
{
PrinterCollection pc = new PrinterCollection();

Console.WriteLine("PrinterCollection...");
Console.WriteLine();
foreach (Printer p in pc)
{
Console.WriteLine(p.DeviceName);
}
}
}
}
 
G

gregarican

Okay, long story I'll try to make short. Our company has a legacy VB6
app running on Citrix. There apparently is some quirkiness in how it
handles the Printers collection for the logged on Citrix user. I don't
have the source code for the legacy VB6 app but am trying to push the
issue with their tech support group. I can tell that native Windows
printer lists for the Citrix session are correct. Through running WSH
scripts, launching a published Citrix Windows Printer folder window,
etc. It's just how the VB6 app handles iterating the printer list
that's the culprit.
To further prove my point I'd like to launch a custom app that lists
the printers in like manner that the MSVBVM60.DLL handles things. I
don't have Visual Basic 6.0 development tools, however. But I do have
Visual Studio 2005 as well as 2008. Here lies my question. Can I add a
reference to Interop.VBA or something in order to iterate the printers
in VB6 manner? When I add that Interop.VBA reference all I see is a
generic Collection object but no sign of the Printer object, the
Printers collection, etc.

// Reference: Microsoft.VisualBasic.PowerPacks.Vs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            EnumeratePrintersCollections();

            Console.WriteLine();
            Console.Write("Press any key to continue...");
            Console.ReadKey();
        }

        public static void EnumeratePrintersCollections()
        {
            PrinterCollection pc = new PrinterCollection();

            Console.WriteLine("PrinterCollection...");
            Console.WriteLine();
            foreach (Printer p in pc)
            {
                Console.WriteLine(p.DeviceName);
            }
        }
    }



}- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -

Awesome! I had Googled across this Powerpack and thought it might be
the right track. Just didn't delve in deep enough. Thanks so much for
your help!
 
G

gregarican

// Reference: Microsoft.VisualBasic.PowerPacks.Vs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            EnumeratePrintersCollections();
            Console.WriteLine();
            Console.Write("Press any key to continue...");
            Console.ReadKey();
        }
        public static void EnumeratePrintersCollections()
        {
            PrinterCollection pc = new PrinterCollection();
            Console.WriteLine("PrinterCollection...");
            Console.WriteLine();
            foreach (Printer p in pc)
            {
                Console.WriteLine(p.DeviceName);
            }
        }
    }
}- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -

Awesome! I had Googled across this Powerpack and thought it might be
the right track. Just didn't delve in deep enough. Thanks so much for
your help!- Hide quoted text -

- Show quoted text -

Other than the handful of global printers defined on the Citrix server
the program seems to error out iterating over the network mapped
printers. If I iterate over the PrinterCollection.Count tally using a
try-catch block then the only Printer.DeviceName items that get
captured okay are those few global ones on the Citrix server. I'll
keep hunting around!
 
G

gregarican

On May 18, 2:11 am, "Jason Keats" <[email protected]>
wrote:
Okay, long story I'll try to make short. Our company has a legacy VB6
app running on Citrix. There apparently is some quirkiness in how it
handles the Printers collection for the logged on Citrix user. I don't
have the source code for the legacy VB6 app but am trying to push the
issue with their tech support group. I can tell that native Windows
printer lists for the Citrix session are correct. Through running WSH
scripts, launching a published Citrix Windows Printer folder window,
etc. It's just how the VB6 app handles iterating the printer list
that's the culprit.
To further prove my point I'd like to launch a custom app that lists
the printers in like manner that the MSVBVM60.DLL handles things. I
don't have Visual Basic 6.0 development tools, however. But I do have
Visual Studio 2005 as well as 2008. Here lies my question. Can I add a
reference to Interop.VBA or something in order to iterate the printers
in VB6 manner? When I add that Interop.VBA reference all I see is a
generic Collection object but no sign of the Printer object, the
Printers collection, etc.
// Reference: Microsoft.VisualBasic.PowerPacks.Vs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            EnumeratePrintersCollections();
            Console.WriteLine();
            Console.Write("Press any key to continue...");
            Console.ReadKey();
        }
        public static void EnumeratePrintersCollections()
        {
            PrinterCollection pc = new PrinterCollection();
            Console.WriteLine("PrinterCollection...");
            Console.WriteLine();
            foreach (Printer p in pc)
            {
                Console.WriteLine(p.DeviceName);
            }
        }
    }
}- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
Awesome! I had Googled across this Powerpack and thought it might be
the right track. Just didn't delve in deep enough. Thanks so much for
your help!- Hide quoted text -
- Show quoted text -

Other than the handful of global printers defined on the Citrix server
the program seems to error out iterating over the network mapped
printers. If I iterate over the PrinterCollection.Count tally using a
try-catch block then the only Printer.DeviceName items that get
captured okay are those few global ones on the Citrix server. I'll
keep hunting around!- Hide quoted text -

- Show quoted text -

Actually the Powerpacks library allows .NET to have similar objects to
VB6. So the semantics of the PrinterCollection object is similar to
iterating over the collection in VB6. But it doesn't wrap around the
VB6 runtime, so the printer list is the same as if I would've invoked
it directly in .NET. I'm looking for something akin to the VBA Interop
library where I can drop down into the VB6 runtime and iterate over
its printer collection (which apparently is buggy under ICA/RDP)....
 
J

Jason Keats

gregarican said:
Actually the Powerpacks library allows .NET to have similar objects to
VB6. So the semantics of the PrinterCollection object is similar to
iterating over the collection in VB6. But it doesn't wrap around the
VB6 runtime, so the printer list is the same as if I would've invoked
it directly in .NET. I'm looking for something akin to the VBA Interop
library where I can drop down into the VB6 runtime and iterate over
its printer collection (which apparently is buggy under ICA/RDP)....

I could write a VB6 DLL for you that will let you retrieve an array of
printers - via COM Interop.

However, I can't really see the point.
 
G

gregarican

I could write a VB6 DLL for you that will let you retrieve an array of
printers - via COM Interop.

However, I can't really see the point.

I appreciate the offer. It's a proof of concept that ICA and RDP
sessions are affected by the VB6 method of handling printers. The
vendor is going to use .NET for the printer selection routine in a
future revision update so the point perhaps would be moot I suppose :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top