Click here to Skip to main content
15,907,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wrote below code for creating shortcut. it is working when I run the program. but after creating setup.i installed setup. after that when I open the application it is giving me exception. what should I do please help me.why I am getting that exception.

       string s5 = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
       WshShellClass shell = new WshShellClass();
       IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(s5 + "\\cater.lnk");
       shortcut.TargetPath = Application.ExecutablePath;
        shortcut.Description = "Any Description here ";

   catch (Exception ex)
Updated 18-Nov-13 1:17am
abbaspirmoradi 18-Nov-13 7:27am    
not clear.what is your exception? where it happens? is your application works fine on local or not?

1 solution

Hello ,
this happens because you have not added
IWshShortcut dll 
in your set up file .you have to add this dll whenever you create the set up . and ensure that these dll must remain in your bin folder .

Share this answer
Dave Kreskowiak 18-Nov-13 7:35am    
Nice guess, but since you have no idea what the exception is you have no idea what the problem is. It could be something else entirely wrong in his code.
hussain548 18-Nov-13 7:40am    
thanks animesh,

please can u tell me how to add iwshshortcut dll at the time of creating setup.
Animesh Datta 18-Nov-13 7:50am    
I think you are using Interop.IWshRuntimeLibrary.dll in your project .

when you are creating set up , add the dll in 'Application Folder' by right click and choose the file (from bin folder). and then build and run the set up .
hussain548 18-Nov-13 8:28am    
Thakns sir,

I tried a lot but u solved my problem. I will be your obligator sir once again thanks.
Animesh Datta 18-Nov-13 8:33am    
Accept the answer . it will helps for others .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900