For most .NET dlls, you can add them as a reference, and then "import" them into your code by means of using directive (e.g. using mydll;
). I have a .NET binary compiled with MSVC which I can add as a reference but it never appears in the using directive. Why could this be happening?
Asked
Active
Viewed 582 times
0

Adam Ralph
- 29,453
- 4
- 60
- 67

dnclem
- 2,818
- 15
- 46
- 64
-
4I don't understand what you're asking. You have to add the `using` directive yourself, have you done that? Also, you're not `using` the assembly itself, you're `using` namespaces in it. – Lasse V. Karlsen Nov 20 '11 at 13:16
-
possible duplicate of [C# Visual Studio 2010 suddenly can't see namespace?](http://stackoverflow.com/questions/4880685/c-sharp-visual-studio-2010-suddenly-cant-see-namespace) – Shadow The GPT Wizard Nov 20 '11 at 13:19
-
I have added the using directive myself, but I get the error 'are you missing a using directive or an assembly reference?' when in fact the reference to the .dll IS there. – dnclem Nov 20 '11 at 13:20
-
@david add reference by right mouse click on project>add reference>find and click OK. Try rebuild project (build>rebuild solution build>rebuild project name). Or just write your constructor from this reference, wait for wrap. Move mouse over the underline word, click it. Then press SHIFTL + ALTL + F10 (or F11 I do not remember). You will get suggestions "What do you want to do" tip. I'm working on VS2010. If you work on different find simillar shortcut for your VSXXXX – deadfish Nov 20 '11 at 13:28
-
If you go into the Object Browser and limit the displayed items to just your referenced DLL, do you see the namespaces and classes you expect? – sq33G Nov 20 '11 at 15:27
1 Answers
1
If you're using a C++/C library, you will have to use dllimport, C# isn't going to just "see" unmanaged code.
[DLLImport( "mydll.dll" )];
static extern void MyMethod(int parm1, int parm2);
then you should be able to call MyMethod from your code as you would any other.

BlackICE
- 8,816
- 3
- 53
- 91
-
It is managed code though.. not unmanaged code. I already mentioned it's a .NET binary. – dnclem Nov 20 '11 at 14:17
-
sorry, missed the .net binary, the comments on the question are good suggestions to start, if they don't help post the additional issues you're having when you try them. – BlackICE Nov 20 '11 at 20:18