blob: b33ea4c70c3432f2345aa05f42b9746e52ff9a36 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Security;
using System.Threading;
using System.Globalization;
using System.Runtime.InteropServices;
public partial class FunctionPtr
{
delegate void VoidDelegate();
public static int Main()
{
RunGetFncSecTest();
int retVal = 100;
VoidDelegate md = new VoidDelegate(FunctionPtr.Method);
Console.WriteLine("\r\nTesting Marshal.GetFunctionPointerForDelegate().");
try
{
Marshal.GetFunctionPointerForDelegate<Object>(null);
retVal = 0;
Console.WriteLine("Failure - did not receive an exception while passing null as the delegate");
}
catch (ArgumentNullException e)
{
Console.WriteLine("Pass - threw the right exception passing null as the delegate");
}
catch (Exception e)
{
retVal = 0;
Console.WriteLine("Failure - receive an incorrect exception while passing null as the delegate");
Console.WriteLine(e);
}
RunGetDelForFcnPtrTest();
return retVal;
}
}
|