0

I am working on a existing c# class library project. I want to add few more class to it. This is then used in a new project. I have added the required classes to the existing typelib project, but when I refer the typelib in the next project and try to access the newly added methods it showing error

The type or namespace name 'abc' does not exist in the name space xyz.TypeLib.core (are you missing assembly reference)

but I can access all those classes which existed previously in that project. I am having issue with newly added files.

Here are the steps I did,

  1. added new classes to the existing project.
  2. Build the project
  3. Added dll to next project from the bin folder of the class library project

Also, as a test I also tried adding a new method in one of the classes which I can access, but this method is not avaiable!

How can I do this properly?

Furqan Safdar
  • 16,260
  • 13
  • 59
  • 93
Zach
  • 9,989
  • 19
  • 70
  • 107
  • There may be a `debug\bin` and a `release\bin` folder. Did you get the DLL from the right one? – Guffa Oct 08 '12 at 10:20
  • Most probable reason could be the change in default namespace. Please check the namespace of all the classes and make sure that it is same what you were using first. I strongly recommend to use source control system to avoid such issues. – Murtuza Kabul Oct 08 '12 at 10:23
  • Thanks for both replies, I have checked both points, and they are ok. – Zach Oct 08 '12 at 10:25
  • Also, as a test I also tried adding a new method in one of the classes which I can access, but this method is not avaiable! – Zach Oct 08 '12 at 10:26
  • 3
    Try adding the library project to your solution and reference that instead of adding a reference to the DLL. – Nasreddine Oct 08 '12 at 10:30
  • Hope you made the classes public and namespace are correct too. Also make sure you first compile to make sure the first project where you added is fine and compilable – Zenwalker Oct 08 '12 at 10:49

2 Answers2

1

1.) Make sure you have added the correct DLL to the project. Therefore, clean the library project, build it, and use that DLL.

2.) (this will most likely be the problem): In Visual Studio, click on the DLL and in the properties, make sure that "Copy to output directory" is set to "Copy if newer".

3.) Re-add the reference to the file.

4.) Clean and then build again your new project that uses the library.

Akku
  • 4,373
  • 4
  • 48
  • 67
1

If the two projects are in the same Visual Studio Solution, the correct approach is to add the class library project directly as a reference. This will bypass any possible dll mismatching that can be caused by other approaches.

Alex Barac
  • 632
  • 4
  • 12