0

I may not be asking this question correctly as I haven't been able to find a reference here or on Google. I need to modify a class that is in one of my reference DLL's. Will VS look at the reference DLL first or the local file first ? It seems to look at the reference DLL first. Is there a way to tell VS which to look at first ?

Thanks

Clarification - I have a class definition in the reference DLL and also in a local project file. The local project file is the class definition that I need the program to use.

  • 3
    Is the class a part of the solution? How have you referenced the class in your solution? – abhi Dec 04 '13 at 14:41
  • Yes, the class is a part of the solution. The class that I need to change, locally, is called from another class definition (also in the DLL reference). I do not instantiate the class directly. – James Bateman Dec 04 '13 at 14:47
  • I don't understand your question quite well: - what is the local file? - is the class you are refering too defined in both, the DLL and your local file? – NobodysNightmare Dec 04 '13 at 14:53
  • Yes, it is defined in both places. I need it to look at the local class definition first. – James Bateman Dec 04 '13 at 14:56
  • 1
    You might want to edit/extend your question further... Best would be if you could provide sample code... This might help in providing better answers. – NobodysNightmare Dec 04 '13 at 15:12
  • Sample code may not help in this particular case. It would be easier to open the project file in a text editor like Notepad++ and look at the references. This has been a very helpful tool in my arsenal. – abhi Dec 04 '13 at 18:50

3 Answers3

1

Using an alias on your references, you can specify which of two similarly named classes you are referring to in your code.

This is explained by Jon Skeet here: What use is the Aliases property of assembly references in Visual Studio 8

Limitations

This will only help you, if you instanciate that class yourself. It is not possible to let a foreign assembly create instances of your own class if there is no dedicated mechanism (i.e. API) for doing so.

Community
  • 1
  • 1
NobodysNightmare
  • 2,992
  • 2
  • 22
  • 33
0

Your question is quite vague, but if you use the Fusion Log Viewer FusLogVw.exe (just search for it on your computer) you can see what dlls are loaded and which paths were used to look for it.

nvoigt
  • 75,013
  • 26
  • 93
  • 142
  • Thanks. Basically, if a Person Class definition exists in a DLL reference and also in a local file, which will VS look at first ? I need it to look at the local definition. – James Bateman Dec 04 '13 at 14:53
0

This depends on how you setup your reference to the project in question. Visual Studio has 2 concepts of references.

  1. Project to Project
  2. Project to DLL

For the sake of this discussion lets call the main project A and the referenced project B (the class to change is located in B)

If there is a project to project reference from A to B then the build is always against the latest source code. Hence if you change the class definition A will always build against the changed class.

If there is a project to DLL reference from A to B then things are a bit murkier. There are so many possibilities here that it is hard to speculate intelligently what will happen. It may get the updated class, it may not, it may after a second rebuild.

In general though if you have 2 projects in the same solution and one references the other you should always use a project to project reference. The easiest way to guarantee this is to delete the reference, right click select add reference and go through the project route instead of "Browse".

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454