Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6065117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:21:18+00:00 2026-05-23T09:21:18+00:00

i am working on SQLCLR integration with Visual C# 2010, what i am trying

  • 0

i am working on SQLCLR integration with Visual C# 2010, what i am trying to do is, i have a folder, which contains some images, my function, iterates thru the file in folder, and get the basic file info like its height width etc..

i created a dll from Visual C# 2010 and added as an assembly in Sql Server 2008, and also created function, but when i try to select function i gets the below error..

A .NET Framework error occurred during execution of user-defined routine or aggregate "fn_GetFiles":   
System.Security.SecurityException: Request failed.  
System.Security.SecurityException:   
   at UserDefinedFunctions.GetFileList(String FolderPath)  
   at UserDefinedFunctions.GetFileInfo(String folderPath)

below is my .net function..

[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]  
public partial class UserDefinedFunctions  
{  
    [SqlFunction(FillRowMethodName = "FillRow")]  
    public static IEnumerable GetFileInfo(string folderPath)  
    {  
        // Put your code here
        return GetFileList(folderPath);
    }

    public static ArrayList GetFileList(string FolderPath)
    {
        ArrayList li = new ArrayList();
        foreach (String s in Directory.GetFiles(FolderPath, "*.jpg"))
        {
            FileInfo info = new FileInfo(s);
            object[] column = new object[3];
            column[0] = Path.GetFileName(s);
            column[1] = info.Length;
            column[2] = s;

            li.Add(column);
        }
        return li;
    }

    private static void FillRow(Object obj, out string filename, out string fileSize, out string filePath)
    {
        object[] row = (object[])obj;
        filename = (string)row[0];
        fileSize = (string)row[1];
        filePath = (string)row[2];
    }

};

here is how i created assembly in sql server..

CREATE assembly GetFileList from 'E:\NBM Sites\DontDelete\SampleCLRIntegration.dll' with permission_set = safe

and created a sql function like below.

ALTER FUNCTION fn_GetFiles   
(  
    @folderPath nvarchar(max)  
)  
RETURNS TABLE   
(  
    [filename] nvarchar(max),  
    fileSize nvarchar(max),  
    filePath nvarchar(max)  
)  
AS EXTERNAL NAME GetFileList.UserDefinedFunctions.GetFileInfo;  

and calling function like below.

select * from dbo.fn_GetFiles('E:\NBM Sites\DontDelete')

How can I fix this error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:21:18+00:00Added an answer on May 23, 2026 at 9:21 am

    You need “External Access” and not “SAFE” permission set. See:

    http://msdn.microsoft.com/en-us/library/ms345106.aspx

    Try:

     with permission_set = EXTERNAL_ACCESS 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working with python interactively, it's sometimes necessary to display a result which is some
Working on calling a C function from my asm project. I'm trying to push
Working with some basic java apps on CentOS 5 linux and I have my
Working with a SqlCommand in C# I've created a query that contains a IN
Working on a project at the moment and we have to implement soft deletion
Working on some matrix code, I'm concerned of performance issues. here's how it works
Working on some legacy hibernate code. How do I do the following with hbm.xml(hibernate
Working in WPF, writing a custom user control. I am trying to change the
Working demo CLick $(document).ready(function(e) { $('span#pijlr, span#pijll').show(); $('#gallery').css('overflow','hidden'); $('span#pijlr').click(function(e) { if (!$('#gallcont').is(':animated')) { var
Working with MVC 2 ad with the help of some friends I thought all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.