2
votes

When I try my CLR UDF, I am getting this error:

Msg 6522, Level 16, State 1, Line 1

A .NET Framework error occurred during execution of user-defined routine or aggregate "getFileSize":

System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

System.Security.SecurityException:

at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)

at System.Security.CodeAccessPermission.Demand()

at System.IO.DirectoryInfo..ctor(String path)

at GetFileInfo.ShowDirectoryName.DirSize(SqlString dir).

Any Idea on how to solve this? I tried to spend some time in BOL but my back is really against the wall right now...

Thanks.

1
Is your SQL UDF finding the size of a file? Looks like whatever user SQL server is running as doesn't have permissions to read the file?Whisk

1 Answers

2
votes

SQLCLR imposes certain restrictions on what your assembly can do, using Code Access Security.

Read up on the various permission sets in SQL:

http://www.devx.com/codemag/Article/31193/0/page/4