I use the print class of FotoVision to make a image print program, why doesn't it work?

I use the print class of FotoVision to make a image print program, why doesn't it work?

The following code is from FotoVision, I make a image print program using the class,
but it doesn't work. Only after I have installed the FotoVision (The name of setup program is " FotoVision Desktop.msi ")
my program just work. I think that FotoVision have packaged some other components such as dll or registered photowiz.dll in its setup program, but I'm not sure.
If so, how can I register photowiz.dll with C# ? Could you help me, thanks!


// Uses the XP Photo Printing Wizard to print one or more photos.
// The implementation of the photo wizard is in photowiz.dll but the
// interface is not exposed. Instead, Microsoft provides the Windows
// Image Acquisition Library (WIA).
//
// Use late binding incase the user does not have the WIA component
// installed (and easier for developers to use the source if it's
// not installed).

// use late binding for this source file
// TRANSINFO: Option Strict Off

using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;

namespace FotoVision {
public sealed class Print {
// const values
private class Consts {
public const string DialogProgId = "WIA.CommonDialog";
public const string VectorProgId = "WIA.Vector";
}

// static class
private Print() {
}

// public methods

// print the specified photo (full path to the photo)
public static void PrintFile( string file ) {
PrintFiles( new string[] { file } );
}

// print the list of photos
public static void PrintFiles( Photo[] photos ) {
// convert to a string array
string[] files = new string[ photos.Length - 1 + 1 ];
for ( int i=0; i<=files.Length - 1; i++ ) {
files[ i ] = photos[ i ].PhotoPath;
}
PrintFiles( files );
}

// print the list of files
public static void PrintFiles( string[] files ) {
try {
// create the vector COM object
object vector = Interaction.CreateObject( Consts.VectorProgId, "" );
Type vectorType = Type.GetTypeFromProgID(Consts.VectorProgId);
// add files to the vector object
foreach ( string file in files ) {
//<TRANSMOD>Late Binding</TRANSMOD>
vectorType.InvokeMember("Add", System.Reflection.BindingFlags.InvokeMethod, null, vector, new object[]{file});
//vector.Add( file );
}

// create the common dialog COM object, and
// display the photo print wizard
//object dialog = Interaction.CreateObject( Consts.DialogProgId, "" );
//<TRANSMOD>Late Binding</TRANSMOD>
object dialog = Interaction.CreateObject( Consts.DialogProgId, "" );
Type dlgType = Type.GetTypeFromProgID(Consts.DialogProgId);
dlgType.InvokeMember("ShowPhotoPrintingWizard", System.Reflection.BindingFlags.InvokeMethod, null, dialog, new object[]{vector});
//dialog.ShowPhotoPrintingWizard( vector );

vector = null;
dialog = null;
}
catch ( Exception ex ) {
Global.DisplayError( "The photo could not be printed.", ex );
}
}

}

}

[3330 byte] By [CUIWEI] at [2007-12-16]
# 1
I haven't worked with FotoVision, but are you trying to run your sample on Windows XP or some other system?
Since it seems from the code coment that this functionality will only work on Windows XP.

What kind of a Dll is photowiz.dll? Since if you want to register it with COM you can use Regserver32 photowiz.dll

Regards,
Saurabh Nandu
www.MasterCSharp.com
www.AksTech.com

SaurabhNandu at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 2
I run FotoVision on Windows XP.
Now I have checked other PC without FotoVision installed, I find photowiz.dll have been registered, so maybe register DLL is not cause!
CUIWEI at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 3
what is the error you get while trying this sample?

Regards,
Saurabh

SaurabhNandu at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 4
Maybe it is "Can't create Active X object"
CUIWEI at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 5

The error information in my program when print is following:
System.ArgumentNullException can't be blank.

Argument name: type

at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at PhotoApp.Print.Printiles(String[] files) in E:\cw\PhotoApp\Print.cs:line 67

CUIWEI at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 6
I think that the installer of FotoVison have added some things to assembly cache of Microsoft .NET Framework 1.1 but I'm not sure what is added.
CUIWEI at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 7
this exception states that you are not passing the right parameters to invoke the method. Please look at the original code to see you pass the right number of parameters to make the method call.

Regards,
Saurabh Nandu
www.MasterCSharp.com

SaurabhNandu at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...