1

This is a console application that I am developing using VS2010 in C#. II got a dll from one of my colleague that I need to use. I added the dll as the reference , added the required name space. Added code to create an instance of the object and used a method from the class. When I finished the code there are no errors reported by VS. When I compiled, I got an error stating 'The Type or namespace name myname could not be found'.

After I got the error, I removed the dll. I removed the name space. Now my code has red underline over where I first reference the class. I hover over it and using intellisense I added the namespace. I used object explorer to make sure it is there. Now I rebuild the solution and I got the same error. I went to object explorer and the dll reference is gone. But when I look at the reference I see the dll still there. I double click to take it to object explorer and the object definition is not there. It is really weird. This is happening only to this dll I got.

What am I doing wrong here?

*** Found the problem. It seems the DLL my friend was build on framework 3.5 with some dependencies. I changed the frame work to 3.5 and now it build properly. Thanks,

Nair
  • 7,438
  • 10
  • 41
  • 69
  • 1
    Which runtime are you targeting and which is the dll build for? – Rune FS Aug 30 '10 at 18:55
  • You might want also to open your project in notepad and copy/paste here the actual reference for this assembly (don't forget to change the assembly names and folder suitably to protect the innocent :-)). – Franci Penov Aug 30 '10 at 19:00
  • Thanks for the comments. For some reason changing the version to 3.5 solved my problem. – Nair Aug 30 '10 at 19:57

2 Answers2

1

When you add the reference, you may want to make sure that CopyLocal is set to True in the properties.

Joel Etherton
  • 37,325
  • 10
  • 89
  • 104
1

Whenever I get this problem, it is almost always because I am targeting the wrong framework.

Ryan Bennett
  • 3,404
  • 19
  • 32