views:

43

answers:

1

I've made a C# class library and am trying to use it in another project. I followed these instructions but am getting the following errors:

The type or namespace name 'TF2Reader' could not be found (are you missing a using directive or an assembly reference?)

The type or namespace name 'Log' could not be found (are you missing a using directive or an assembly reference?)

I'm copying the DLL to the project's own directory but when viewing the reference in the Object Browser there are no classes when expanded. Why is this library not loading?

+3  A: 

The instructions in the page you linked to recommend that you browse to the compiled DLL for the library when adding the reference. I don’t know why they would recommend that. It’s weird. You should use that only if the compiled binary of the library is all you’ve got.

The normal, recommended practice is to add both projects (the library and the project that uses the library) to the same solution, so you can edit them both in Visual Studio together, and compile them together. Then, in the Add Reference dialog, instead of the Browse tab you use the Projects tab, which will list your library.

This way, your code will always know about all your up-to-date changes in the library. If you declare a new type in the library, you can immediately use it in the other project; no need to recompile the library first and make sure that DLL files are copied to the appropriate places etc.

Timwi
This sounds a lot saner than compiling and referencing. I'll give this a go tomorrow, however I will have to import a library I don't have the source for as well - but I'll bring up a new question if that doesn't work. Thanks!
Ross