简体   繁体   中英

Use internal static class methods from external dll using c#

I have an assembly A in which code like

namespace A{
    internal static class SourceData
    {
        static SourceData()
        {    
            //some code
        }   
        [MethodImpl(MethodImplOptions.NoInlining)]
        public static string getdata(string name)
        {
            return (string) null;
        }
    }
}

now I referenced that dll in my project and I want to access getdata() method, Is is possible? and If yes, then how? Thanks.

In your Assembly A, you could add the InternalsVisibleTo attribute: https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute%28v=vs.110%29.aspx

You should of course consider just making it public if it is something to be used in other assemblies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM