Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi am new to .Net. as per my business requirements I have to zip the files based on filename in data table account number column. If file name is matched ,we have zip total matched files with password protection. I wrote code to zip files .It's working in console application. Not in working in CLR stored procedure. While executing store procedure getting error.

.Net framework error occurred during execution of user defined routine or aggregate . System security.security exception

I given permission to DLL as external access.

What I have tried:

Here is my code for zipping folder.
C#
Sting path= @"c:\program files\ 7z\7z.exe";

String Destinationfolder=@"d:\temp\";
String Source folder=@"E:\myfiles.zip";

Processstartinfo pro= new processstartinfo ("cmd.exe");
Process p=new process ();
Pro.windowstyle= processwindowstyle.hidden;
Pro.filename= path;
Pro.arguments="a -p passwordd+ "\""+Destination folder+"\""+ source folder+"\"";
Process x= process start(pro);
X.waitforexit();
Int status= x.exitcode;

What's is my mistake in code. Am using .Net framework 4

Thanks for advance
Posted
Updated 7-Jan-17 3:20am
v3

Since you're starting a new process, not just using files etc, try defining the assembly as UNSAFE instead of EXTERNAL_ACCESS

Depending on your situation, you may also need to set TRUSTWORTHY Database Property[^] on.
 
Share this answer
 
Comments
Wendelius 7-Jan-17 9:39am    
To answer your question in Solution 2: "Can you give brief description on external access, safe,unsafe. In which Cases we have go with external access, or safe or unsafe".

Have a look at Creating an Assembly[^] I think that article explains the differences quite well. It's hard to say exact boundaries for external_access but many "low level" operations may use Win32 API and that would require unsafe.
Yes. It's working. Can you give brief description on external access, safe,unsafe. In which Cases we have go with external access, or safe or unsafe. Thanks for advance
 
Share this answer
 
Comments
Wendelius 7-Jan-17 9:41am    
When replying to a post, use the "Have a Question or Comment" -button. This way the original poster gets notified.

Deleting this solution might be a good idea since it's not actually a solution. Just hover over your solution and press the big red X :)

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