DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Thu, 26 Jul 2007 02:37:33 -0700,    posted on: microsoft.public.dotnet.framework        back       

Thread Index
  1    unknown
          2    torben
                 3    torben


.NET 3.0 System.Printing   
Hi there,

i try to clone a printer .. just as it was posted at
http://msdn2.microsoft.com/en-us/library/aa970846.aspx
"How to: Clone a Printer"

but i got problems when setting PrintQueueAttributes ... is there
anyone who can show me the way getting
from PrintPropertyDictionary to PrintQueueAttributes (btw. casting
does not work :-) ) or to show me how to Set the
PrintQueueAttributes ...

below you´ll find the script taken from ms-website...
when starting this i´m getting an  InvalidCastException at the
"myPrintProperties" (type:PrintPropertyDictionary ) parm...

Exception:
System.InvalidCastException: Das Objekt des Typs
System.Printing.PrintQueueAttributes kann nicht in Typ System.Int32
umgewandelt werden.

>> THERE IS NO PrintQueueAttributes  !! its PrintPropertyDictionary


Code:
clonedPrinter = myLocalPrintServer.InstallPrintQueue(printQuename,
printDriver, pport, printPrcessorName, myPrintProperties);


thanks alot....
torben

-------snip--------

LocalPrintServer myLocalPrintServer = new
LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer);
PrintPrintServer(myLocalPrintServer, rtb);
PrintQueue sourcePrintQueue = myLocalPrintServer.DefaultPrintQueue;
PrintPropertyDictionary myPrintProperties =
sourcePrintQueue.PropertiesCollection;

// Share the new printer using Remove/Add methods
PrintBooleanProperty shared = new PrintBooleanProperty("IsShared",
true);
myPrintProperties.Remove("IsShared");
myPrintProperties.Add("IsShared", shared);

// Give the new printer its share name using SetProperty method
PrintStringProperty theShareName = new
PrintStringProperty("ShareName", "\"Son of "  sourcePrintQueue.Name 
"\"");
myPrintProperties.SetProperty("ShareName", theShareName);

// Specify the physical location of the new printer using Remove/Add
methods
PrintStringProperty theLocation = new PrintStringProperty("Location",
"the supply room");
myPrintProperties.Remove("Location");
myPrintProperties.Add("Location", theLocation);

// Specify the port for the new printer
String[] port = new String[] { "COM1:" };

// Install the new printer on the local print server
string printQuename = "Torsten Virtual Printer Copy";
string printDriver = sourcePrintQueue.QueueDriver.Name;
PrintString(printDriver, rtb);
string printPrcessorName =
sourcePrintQueue.QueuePrintProcessor.ToString();
PrintString(printPrcessorName, rtb);
string[] pport = new string[] { sourcePrintQueue.QueuePort.Name };
PrintString(sourcePrintQueue.QueuePort.Name, rtb);

clonedPrinter = myLocalPrintServer.InstallPrintQueue(printQuename,
printDriver, pport, printPrcessorName, myPrintProperties);

myLocalPrintServer.Commit();

----------snap------------
Date:Thu, 26 Jul 2007 02:37:33 -0700   Author:  

RE: .NET 3.0 System.Printing   
that is the complete exception ...

System.InvalidCastException: Das Objekt des Typs 
System.Printing.PrintQueueAttributes kann nicht in Typ System.Int32 
umgewandelt werden.
   bei 
MS.Internal.PrintWin32Thunk.DirectInteropForPrintQueue.PrinterInfoTwoSetter.SetAttributes(IntPtr printerInfoTwoBuffer, Object value)
   bei 
MS.Internal.PrintWin32Thunk.DirectInteropForPrintQueue.PrinterInfoTwoSetter.SetValueFromName(String valueName, Object value)
   bei System.Printing.PrintQueue.Install(PrintServer printServer, String 
printQueueName, String driverName, String[] portNames, String 
printProcessorName, PrintPropertyDictionary initializationParams)
   bei System.Printing.PrintServer.InstallPrintQueue(String printQueueName, 
String driverName, String[] portNames, String printProcessorName, 
PrintPropertyDictionary initialParameters)
Date:Thu, 26 Jul 2007 03:16:00 -0700   Author:  

RE: .NET 3.0 System.Printing   
Problem solved..there was an uninitialized property..

Getting all possible properties :

PrintPropertyDictionary printQueueProperties = 
defaultPrintQueue.PropertiesCollection;

				PrintString(String.Format("These are the properties, and their types, of 
{0}, a {1}", defaultPrintQueue.Name, defaultPrintQueue.GetType().ToString() + 
"\n"), rtb);

				foreach (DictionaryEntry entry in printQueueProperties)
				{
					PrintProperty property = (PrintProperty)entry.Value;

					if (property.Value != null)
					{
						PrintString(String.Format(property.Name + "\t(Type: {0})", 
property.Value.GetType().ToString()), rtb);
					}
				}

"torben" wrote:


> that is the complete exception ...
> 
> System.InvalidCastException: Das Objekt des Typs 
> System.Printing.PrintQueueAttributes kann nicht in Typ System.Int32 
> umgewandelt werden.
>    bei 
> MS.Internal.PrintWin32Thunk.DirectInteropForPrintQueue.PrinterInfoTwoSetter.SetAttributes(IntPtr printerInfoTwoBuffer, Object value)
>    bei 
> MS.Internal.PrintWin32Thunk.DirectInteropForPrintQueue.PrinterInfoTwoSetter.SetValueFromName(String valueName, Object value)
>    bei System.Printing.PrintQueue.Install(PrintServer printServer, String 
> printQueueName, String driverName, String[] portNames, String 
> printProcessorName, PrintPropertyDictionary initializationParams)
>    bei System.Printing.PrintServer.InstallPrintQueue(String printQueueName, 
> String driverName, String[] portNames, String printProcessorName, 
> PrintPropertyDictionary initialParameters)
> 
> 
Date:Thu, 26 Jul 2007 03:40:01 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us