Call function from DLL?

后端 未结 5 780
灰色年华
灰色年华 2020-12-14 06:36

I\'m new to C# and I\'m trying to learn to usage of DLLs. I\'m trying to wrap my objects in a DLL, and then use it in my program.

public class Foo   // its in         


        
5条回答
  •  -上瘾入骨i
    2020-12-14 07:29

    I am late to the party here but am leaving this answer for someone pulling his/her hair out like me. So basically, I did not have the luxury of VS IDE when facing this issue.I was trying to compile the code via cmdline using csc. In order to reference a dll, just add the compiler flag /r:PathToDll/NameOfTheDll to csc.

    The command would look like

    csc /r:PathToDll/NameOfTheDll /out:OutputExeName FileWhichIsReferencingTheDll.cs

    In FileWhichIsReferencingTheDll.cs add using namespace AppropriateNameSpace; to access the functions (by calling class.functionName if static or by creating an object of the class and invoking the function on the object).

提交回复
热议问题