Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
WinApp failing after publishing on Security.Permission.FileIOPermission


Request for the permission of type 'System.Security.Permissions.DileIOPermission


at System.Windows.Forms.Application.get_StartupPath()
Posted
Comments
Sergey Alexandrovich Kryukov 11-Sep-13 12:04pm    
Not a question, not enough information. Any code sample?
—SA
Smitha Roslin Tom 12-Sep-13 1:19am    
I am trying to execute a windows application. On Main() function i am using a code
string strConnString = "Provider=SQLBASEOLEDB;Data Source=DBSHIP;User Id=SYSADM;Password=panda1;ini=" + Application.StartupPath + "\\Sql.ini";
In this line a get the exeception.

Request for the permission of type 'System.Security.Permissions.DileIOPermission.....

at System.Windows.Forms.Application.get_StartupPath() . How it happend this file has permission and i can create a text file in working folder. send me a solution
Sergey Alexandrovich Kryukov 12-Sep-13 1:26am    
Looks weird. Okay, what's the exact location of the entry assembly and what are the permissions on this directory?
—SA
Smitha Roslin Tom 12-Sep-13 1:31am    
permission for everyone

1 solution

By the way, more universal and correct method of the executable directory is this:
C#
string location = System.Reflection.Assembly.GetEntryAssembly().Location;
string executableDirectory = System.IO.Path.GetDirectoryName(location);


I don't think it will eliminate the exception, but this method works when other methods give incorrect results (for example, when application hosting is different).

As to your problem, please see my question in the comments to your question and answer it.

—SA
 
Share this answer
 

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