How to call unmanaged functions that are implemented in a DLL file with security exception in C#

1 Answer

0 votes
using System;
using System.Runtime.InteropServices;
using System.Security;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        [DllImport("msvcrt.dll")]
        public static extern int puts(string c);

        static void Main(string[] args)
        {
            try
            {
                puts("c# programming");
            }
            catch (SecurityException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}


/*
run:

c# programming

*/

 



answered Apr 28, 2017 by avibootz

Related questions

1 answer 3,976 views
1 answer 184 views
1 answer 101 views
1 answer 188 views
...