dynamic loading - Cant access C# static class -
dynamic loading - Cant access C# static class -
i having problem implementing reply got here!, can help me access private static class?
namespace veparametertool { class processorplugin { private static class unsafenativemethods { [dllimport("kernel32", setlasterror = true, charset = charset.ansi)] static extern intptr loadlibrary([marshalas(unmanagedtype.lpstr)]string lpfilename); [dllimport("kernel32", charset = charset.ansi, exactspelling = true, setlasterror = true)] static extern intptr getprocaddress(intptr hmodule, string procname); [dllimport("kernel32", setlasterror = true)] static extern bool freelibrary(intptr hmodule); } [unmanagedfunctionpointer(callingconvention.cdecl)] private delegate errorcode processorfunction(ref intptr prx); intptr hlib = unsafenativemethods.loadlibrary("processor.dll"); } } when seek loadlibrary, error protection levels:
'veparametertool.processorplugin.unsafenativemethods.loadlibrary(string)' inaccessible due protection level i have searched solution cant see static classes.
any hep appreciated.
andy
you can leave inner class private, making accessible processorplugin class, have create methods public.
private static class unsafenativemethods { [dllimport("kernel32", setlasterror = true, charset = charset.ansi)] public static extern intptr loadlibrary([marshalas(unmanagedtype.lpstr)]string lpfilename); [dllimport("kernel32", charset = charset.ansi, exactspelling = true, setlasterror = true)] public static extern intptr getprocaddress(intptr hmodule, string procname); [dllimport("kernel32", setlasterror = true)] public static extern bool freelibrary(intptr hmodule); } these methods accessible containing class can accessed, in example, processorplugin.
c# dynamic-loading
Comments
Post a Comment