cannot add a reference .NET

后端 未结 6 1858
独厮守ぢ
独厮守ぢ 2021-02-05 22:50

I have a DLL which I would like to add as a reference to my project, but everytime I try to do it a dialog pops up telling me:

The reference could not be

6条回答
  •  南旧
    南旧 (楼主)
    2021-02-05 23:39

    You can not add unmanaged DLLs as references in Visual Studio, regardless of the 32/64 "bittyness". And I doubt that it worked on your x86 machine.

    There's a difference between "normal" DLLs and COM-DLLs.

    You can add a reference to a COM-DLL after it was registered with the system (actually you reference the exposed COM object and a reference to the DLL is added automatically). This can be done on the "COM"-Tab of the "Add reference" dialog (here you have to make sure that your project is built as a x86 target in most cases).

    "normal" DLLs can - as I said - not be added at all. You can include them in the solution (right click solution, select "Add existing file"), but they will not be referenced unless you declare something like

    [DllImport("...")]
    public static extern void MyFunction();
    

    I suspect that in your other solution, there's some kind of wrapper DLL, which you are actually referencing and which contains the DLL imports.

提交回复
热议问题