[.net] add reference to project

Started by
4 comments, last by MartinLoga 13 years ago
Hi,

I'm working on an application using severall libraries. Application and libraries are developed by our own. So all code is available to me.
My first approach of corse was to put all in to one solution and start working. I referenced the libraries via the project name in the Dialog "Add Reference" and everything was fine.

But some internal conventions in this project forbid me to reference by project name so now I had to switch to reference by path to dll (see "search" tab in the Dialog "Add Reference"). The Application still works of course BUT from now on neither intelli sense nor refactoring works properly.

E.g.:
1. If I'm in the application and try to jump to the definition of a method contained in one of the libraries this won't work. Instead VS jumps in to a generated interface file.
2. Or if I change a method in one of the libraries the refactoring does not work for the application using this method.

So in the end it cost much more time to work on the code now and I wonder if there is any way to tell VS that there is in fact source code available and that it has to use it.

Thanks for any help.

Martin
Advertisement

I wonder if there is any way to tell VS that there is in fact source code available and that it has to use it.


Maybe I'm missing something but IMO this is what the "Reference to Project" is for.

Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development

You should be able to step into the C# source code of a project that is in another solution provided that:

1. you reference the debug dll.
2. you generated a pdb for the target dll and it is in the same directory as the referenced dll
3. the source code is in the exact same (absolute) location that it was when you generated the dll.

VS can be kinda cryptic and some settings can disrupt this process like loading assemblies that were built under different configurations or stepping across marshal boundaries (and well sometimes VS just seems to have bad days), but verifying your pdb files is the first step.

If you are not using C# things may be different.

Hope this helps.
Maybe I'm missing something but IMO this is what the "Reference to Project" is for.[/quote]
Correct. As I said. I'm not allowed to use "Reference to Project".

You should be able to step into the C# source[/quote]
Debugging works perfectly. But e.g. Intelly sense is not. And also navigation in source code is not working (like "jump to definition").
I must correct intelly sence is still working. I wanted to say that refactoring is not working across projects since it is not references by project but by dll.
DEbugging is working just fine. That is not my problem ...

In the attachement I have generated a simple vs solution to show you the problem.

The difference between ConsoleApplication1 and ConsoleApplication2 is that in
ConsoleApplication1 I have referenced by project and in ConsoleApplication2 I have referenced by dll.
Again I have to reference by dll. Because this is our project policy.

code navigation

1. open ConsoleApplication1 Programm.cs
2. right click on the method "bar" and select "goto definition"
-> it will jump to ClassLibrary1::Class1::bar
3. no do the same at ConsoleApplication2 Programm.cs
-> it will jump in to a generated file based on the interface of Class1 instead of jumping to the actual code -> how can I fix this?

refactoring

1. open ClassLibrary1::Class1
2. change name of method bar to foobar and tell him to refactor this in this solution
-> it will change ConsoleApplication1 Programm.cs correctly
-> but it will not change ConsoleApplication2 Programm.cs -> how can I fix this?

I hope now my question is clear.
Unfortunately I don't know how to get VS to do cross solution refactoring or how to do VS style code navigation across solutions outside of debugging. I suspect that this is simply not supported. The simple fix is to put all the projects you want to refactor in the same solution and to reference the projects by project name. If this is against your your organization's conventions you might consider petitioning to have the conventions changed. There may be some way to get around this, but it is beyond my knowledge.

Sorry I could not help you more.
Good luck.
Thanks anyway. Than I will have a simple local copy of the original solution when Im working on it so I can reference by project.

This topic is closed to new replies.

Advertisement