There is a Windows Forms that has worked on the client’s machine for a couple of years. Then the Imaging application (Drevnyuchaya image viewer) was installed on that machine and the .tif format files were associated with it. Now, when the application processes .tif files, an error occurs.

The specified file is not associated with any application to perform this operation.

The application code is:

 ProcessStartInfo info = new ProcessStartInfo(); info.Arguments = "\"Universal Document Converter\""; info.Verb = "Printto"; info.FileName = file_name; info.UseShellExecute = true; info.WindowStyle = ProcessWindowStyle.Hidden; Process p = new Process(); p.StartInfo = info; p.Start(); //На этой строчке вылетает ошибка p.WaitForExit(); p.Close(); p.Dispose(); 

I checked in the Панели управления -> Программы по умолчанию -> Сопоставление типов файлов или протоколов конкретным программам , there were no .tif and .tiff files at all. I added them to that list and associated them with the standard Windows viewer. But the error occurred as it appears. Uninstalling the Imaging program did not help either. What else can you do?

PS I can not roll back the system, unfortunately.

  • If you have a similar system, you can spy on the print processor for tiff in the registry. - VladD
  • In the file_name variable, do you think the program should be indicated to run, is it installed on the PC? - sp7
  • @VladD: I copied the keys HKEY_CLASSES_ROOT\.tif and HKEY_CLASSES_ROOT\.tiff from the test machine (on which the application runs) to the problematic machine. Did not help. I do not know other keys, tell me? - user200141
  • @Olegg Degtev: I do not know either, but I think that the registry should be found by a close look (and search). And take a look at HKCU (on both machines). - VladD
  • @ sp7: in file_name lies the file being opened, in this case the image tif . But since it is worth launching from under the shell info.UseShellExecute = true; , the picture should open in the associated application by default. But instead, an error pops up. - user200141

1 answer 1

First, check what happens when you "run" a file with a .tif extension as a user. Standard windows viewer opens?

Check if the "Universal Document Converter" setting has fallen off as a printer. As far as I understand, this program uses a driver recognized as a printer to convert the image.

For starters, try sending a tif from a graphic editor / viewer manually to this “priter”.

Next, try executing your code, but without specifying info.Verb = "PrintTo"; . Open image view?

Next, try to automate the choice of a printer, maybe something is wrong with its name. For example, there could appear a second copy, i.e. tsiferka at the end.

 using (PrintDialog printDialog1 = new PrintDialog()) { if (printDialog1.ShowDialog() == DialogResult.OK) { System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(); info.Arguments = "\"" + printDialog1.PrinterSettings.PrinterName + "\""; info.FileName = file_name; info.CreateNoWindow = true; info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; info.UseShellExecute = true; info.Verb = "PrintTo"; System.Diagnostics.Process.Start(info); } } 

If this does not help, then check to see if after that ill-fated Imaging program there are no incorrect settings for a particular PrintTo willow, you need to look in the registry. To find out, use the assocs and ftype . The assoc shows what the file extension is associated with. This can be either a program or a "file type".

At the command prompt:

 assoc .tif assoc .tiff 

In a normal situation should return, respectively:

.tif = TIFImage.Document

.tiff = TIFImage.Document

Further, the ftype command helps to understand what lies behind the association with the TIFImage.Document type, again through the command line:

 ftype TIFImage.Document 

should return something like:

TIFImage.Document =% SystemRoot% \ System32 \ rundll32.exe "% ProgramFiles% \ Windows Photo Viewer \ PhotoViewer.dll", ImageView_Fullscreen% 1

If ftype does not return this, then you must manually restore the association and parameters of the TIFImage.Document type from the live OS. Particulary,

 HKEY_CLASSES_ROOT\TIFImage.Document\shell\printto\command 

value should be similar to (specified for windows 10)

 "%SystemRoot%\System32\rundll32.exe" "%SystemRoot%\System32\shimgvw.dll",ImageView_PrintTo /pt "%1" "%2" "%3" "%4" 
  • Manually prints fine from any viewer. - user200141
  • @Olegg Degtev I wrote how to give the opportunity to choose a printer, try, maybe something is wrong with the name constant. - Zverev Evgeniy
  • The problem as I understand it is not in the printer itself, but in the program that sends the file to print. Windows can not choose which program to open the file to send to print. - user200141
  • @Olegg Degtev What happens when you simply "run" a file with the .tif extension as a user? Does the standard Windows viewer open? - Zverev Evgeniy
  • Yes, everything manually opens and prints as it should - user200141