VS2008 Deployment - File Type Properties - Application did not register correctly the open verb

Question

• Hi everyone,

I am using VS2008 to build a c++ application. I built my application successfully, and use a .vdproj setup and deployment project to redistribute it. The files (including DLLs needed by my app) are distributed properly on the target File System, and the application runs correctly.

I am trying to associate my file type .xyz to open it with my application when a file of type .xyz is double-clicked. For that purpose, i followed the instructions of http://msdn.microsoft.com/en-us/library/c219k91z(v=VS.90).aspx

My file type properties window looks like this:

Name         MyFileType.xyz
Command   Primary Output from MyApplication (Release Win32)
Description My file type
Extensions  xyz
Icon           (Icon)
Mime:

Then I added an &Open Action:

(Name)      &Open
Arguments "-startup %1"
Verb          open

I am indeed expecting following to be called when a user double-clicks on the C:\path\to\file.xyz file:

File System on Target Machine\Application Folder\Primary Output from MyApplication (Release Win32) -startup C:\path\to\file.xyz

However, when I deploy the application, the behaviour is not the one i expected, although the file type .xyz seems to be registered properly:  the icon is set correctly, but when i double click on a .xyz file, i can see briefly in the Processes list of the task manger my application show up, but it disappears very fast.

In the registry editor, under HKEY_CLASSES_ROOT\.xyz, i can see an entry MyFileType.xyz that itself has an entry ShellNew with name (Default), Type REG_SZ and Data (value not set).

Can someone help me and tell me what went wrong ?

Tuesday, March 01, 2011 2:37 PM

All replies

You need to write the Arguments like this:

"-startup" "%1"

And then set this action Set As Default.

And in the Program.cs we use the second parameter to pass the file path:

    static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1(args[1]));
}


And write a overwrite constructor for Form1 to recieve the parameter, file path.

The following is my test project, you can download it can test it in you side:

http://cid-bb789f72272d4858.photos.live.com/self.aspx/2011/2011Y03M/WindowsFormsApplication5.zip

If there's any concern, please feel free to let me know.

Have a nice weekend!

Mike [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Sunday, March 06, 2011 9:19 PM
• Hi Mike,

However, I am now facing another problem: double clicking the xyz file starts my application in the current folder, and not in "File System on Target Machine\Application Folder\Primary Output from MyApplication (Release Win32)".

As I am expecting some plugins in a subdirectory of "File System on Target Machine\Application Folder\Primary Output from MyApplication (Release Win32)", my applications quits saying it did not find the expected DLLs.

Is this expected behaviour and if yes how can I solve this ?

Wednesday, March 09, 2011 6:18 PM

You said you expect some plugins in a sub directory of the application folder, but then you said that the application quits and said it did not find the expected DLLs. What do you mean?

Do you mean if the *.xyz file doesn't exists in the application, then you want the application show user that error?

Or this errors occur now, but you just want to solve this issue?

Have you tried to open a file under the application folder, if there's also this error?

Or have you tried just not use the start parameters to republish your application, and test it, if there's also this error?

I think I need to know more about the real design and the situations of this application on this feature, so can you provided those description?

If there's any concern, please feel free to let me know.

Mike [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Thursday, March 10, 2011 4:34 PM
• Hi Mike,

thank you for your answer. Sorry if my last post was not clear, i will try to reformulate.

>Do you mean if the *.xyz file doesn't exists in the application, then you want the application show user that error?

No i do not mean that.

>I think I need to know more about the real design and the situations of this application on this feature,
>so can you provided those description?

OK. Let me try to describe my problem again.

My application installs successfully on "File System on Target Machine\Application Folder\Primary Output from MyApplication (Release Win32)".
For a successful start, my application needs to load plugins from a "plugins" subdirectory, which is installed in
"File System on Target Machine\Application Folder\Primary Output from MyApplication (Release Win32)\plugins".
So when i start my application from "File System on Target Machine\Application Folder\Primary Output from MyApplication (Release Win32)", everything is fine, and I can load my .xyz files successfully within my application.

However, when i double-click on the file C:\path\to\file.xyz in an explorer windows, it seems that my application is started in "C:\path\to" and _not_ in "File System on Target Machine\Application Folder\Primary Output from MyApplication (Release Win32)".
The consequence is that the plugins are not found (indeed, theres is no "plugins" directory in  "C:\path\to") and that my application does not start successfully.

So my question is: is there a way to specify that the application must always be started in "File System on Target Machine\Application Folder\Primary Output from MyApplication (Release Win32)", even when double clicking on a .xyz file that can be anywhere on the system ?

Friday, March 11, 2011 11:13 AM

I would like to let you ensure how you load the plugins, which path do you use, the file path or the application executable path?

I think the root cause is in the load plugins methods side, not the setup project or the whole solution, it is just the method you used.

We can see the start path is also the primary output path according to the command value in the registry(MyFileType.xyz under HKEY_CLASSES_ROOT).

I have made a test using the following sample code:

And then add my project's code into this project, to let it can support pass a file path and display the content from the file to the RichTextBox.

Then add a setup project to this solution, and add the Citrus.Forms.PluginManager primary output content and resource to the setup project, And then drag the plugins folder to the "Application Folder" in the "File System Editor".

Then do the "File Type" settings in the "File Type Editor" page as you said in your original post.

Then we can build it and setup this project to system.

All are working fine in our side.

Have a nice weekend!

Mike [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Monday, March 14, 2011 6:12 AM
• Hi Mike,

i posted a new thread here:

Thank you,

Monday, March 14, 2011 4:12 PM

You're welcome.

If I have any opinions, I will post my reply on that new thread.

Have a nice day!

Mike [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Wednesday, March 16, 2011 6:35 AM