Pregunta

I have installed DYMO_Label_v.8_SDK_Installer.exe and the default v8.x label printing software. The code runs fine on my machine, but when I publish it to an iis server it gives me this message:

<Error>
  <Message>An error has occurred.</Message>
  <ExceptionMessage>Printer '\\pcname\DYMO' is not found</ExceptionMessage>  
  <ExceptionType>System.InvalidOperationException</ExceptionType>
  <StackTrace>   at System.Web.Http.ApiController.<InvokeActionWithExceptionFilters>d__1.MoveNext()
     --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__0.MoveNext()    
  </StackTrace>
</Error>

And the strange thing is that I have added the \\pcname\DYMO and can print to it. When I browse to \pcname it shows me this shared dymo printer. Everything works when I run my code locally, but when it is deployed with the same settings in the web.config it cannot find the printer?

StringBuilder sb = new StringBuilder
var label = DYMO.Label.Framework.Label.Open(System.Web.HttpContext.Current.Server.MapPath(@"~/Content/thelabel.label")); // mvc webapplication
label.SetObjectText("Address", sb.ToString());
label.Print(ConfigurationManager.AppSettings.Get("printername"));
// printername = \\pcname\dymo

Now I have read something about 32 and 64 bit versions of the sdk, but that would give me a different error right? local testing is also on a x64 machine. No iis, but iisexpress or developmentserver I think. And the sdk that I have downloaded is the latest I think, which should work for both x86 and x64 machines according to the dymo blog.

Edit This code does not list any printer. But the dymo software can print (from the same pc). the labelprinter is listed when I look at the printers in the windows controlpanel.

StringBuilder sbPrinters = new StringBuilder();
DYMO.Label.Framework.Printers p = new DYMO.Label.Framework.Printers();
foreach(var printer in p.ToList())
{
    sbPrinters.AppendLine(printer.Name);
    sbPrinters.AppendLine(printer.ModelName);
    sbPrinters.AppendLine(printer.IsConnected.ToString());
    sbPrinters.AppendLine(printer.IsLocal.ToString());
    sbPrinters.AppendLine("-==========-");
}
return sbPrinters.ToString(); // empty...

edit2 just tested it at win2003 on .net 4 instead of 4.5 and it does not list any printers. So both 2003 and 2012 do not work. Windows 8.1 does work. Same code, same network shared printer. The dymo label v8 software can print from 2003, 2012, 8.1. so the printer is installed properly. I also tried impersonation in the web.config on 2003 to run as administrator. But that did not work. When I ran this command in the screenshot below and copy pasted the printer name into the web.config file it still cannot locate the installed printer.

enter image description here

¿Fue útil?

Solución

Took me a while, but the problem is IIS. (Tested in iis6 with .net 4 on win2k3 and iis8 on .net 4.5 on win2012)

http://www.jphellemons.nl/post/Working-with-the-Dymo-label-sdk-on-Windows-2012-server

long story short: I used the katana project; owin for .net to host a rest service.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top