6 Replies - 5006 Views - Last Post: 11 January 2014 - 12:55 PM Rate Topic: -----

#1 m_wylie85   User is offline

  • D.I.C Addict
  • member icon

Reputation: 96
  • View blog
  • Posts: 899
  • Joined: 15-October 10

Programmatically add dll references

Posted 11 January 2014 - 10:37 AM

HI all. I am trying to make a utility program for work that will update multiple projects with local dll references. Basically I work with two solutions (for talk sake solutIon1 and solutIon2). Generally solutIon1 will reference the dll's built In solutIon2 which reside on a server. However for debugging proposes I sometimes need to D/L the solutIon2 projects and build them local-ally, so that I can reference the solutIon2 dll's local-ally (this Is so that I can easily attach the dll and step Into the code). However this require changing the reference paths, so that I am pointing to the local-ally built dll's, which Is quite a laborious task.

So the question is how would I update references in solution1 from the program that I am making. I don't really know what to start reading about as I have never done anything like this before.

If any of this is unclear please ask and i will try to clarify what I mean.

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Programmatically add dll references

#2 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6537
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: Programmatically add dll references

Posted 11 January 2014 - 11:01 AM

Don't you have the DLL's as links in the Visual Studio solution?
Not to mention DLL's load by path, so if your company updates the DLL's you're going to just replace them and the program won't know the difference.

One way you could do it is by paths. If you network server is K:, you could have a local second drive like a USB drive that gets mounted as K:... So if you drop the network and plug in the local drive you still have a K: drive and your solution should transparently switch from one to the other.

Mostly it just sounds like a screwed up setup to begin with.
Are you using any kind of source code control such as Perforce?
Normally that means the developer works a local copy of everything. When a new version is submitted to source control everyone sees that their local copy is need of update and they grab it.
Was This Post Helpful? 1
  • +
  • -

#3 m_wylie85   User is offline

  • D.I.C Addict
  • member icon

Reputation: 96
  • View blog
  • Posts: 899
  • Joined: 15-October 10

Re: Programmatically add dll references

Posted 11 January 2014 - 11:14 AM

Yes well are using source safe as are source control and yes i do have the dll's referenced in visual studio for example: x\pathname. I understand what you are saying about the dropping the network drive and having another drive with the same same letter (x for talk sake) that is a good idea but i would rather this program just looped through the solution1 projects and changes the reference paths to a path that i specify e.g c:\theFolderPath etc can an external program loop through projects within a solution and change the ref paths?
Was This Post Helpful? 0
  • +
  • -

#4 m_wylie85   User is offline

  • D.I.C Addict
  • member icon

Reputation: 96
  • View blog
  • Posts: 899
  • Joined: 15-October 10

Re: Programmatically add dll references

Posted 11 January 2014 - 11:29 AM

The reason that i want to do it this way is that if i need to replicate code into an old version of the of a project. I have to download both solutions and when they are downloaded the solution1 References will be pointing to the latest version of soluation2's dll's on the x drive but if i am changing something in one of the projects in solution2 i need to point the solultion1 projects the the version of the solultion2 dll's that i am change to make sure that i don't inadvertently brake part of the code. It would there for be easier and quick for me to write this program that i can specify where i want solution 1 references to point to.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15685
  • View blog
  • Posts: 62,824
  • Joined: 12-June 08

Re: Programmatically add dll references

Posted 11 January 2014 - 12:02 PM

References are typically at compile time and dealt with by the solution... even rearranging them would require a recompile.. so unless you are going to go the route of making some sort of VS plugin to do it this sort of fringe case would best be done by hand..
Was This Post Helpful? 0
  • +
  • -

#6 m_wylie85   User is offline

  • D.I.C Addict
  • member icon

Reputation: 96
  • View blog
  • Posts: 899
  • Joined: 15-October 10

Re: Programmatically add dll references

Posted 11 January 2014 - 12:14 PM

I understand this would be better to do by hand but it drives me crazy having to change the refs all the time. I guess i will go down the route of make a VS plugin as the i know how to loop through projects within a solution. I just didn't know how to loop through projects in a separate solution.
Was This Post Helpful? 0
  • +
  • -

#7 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7360
  • View blog
  • Posts: 24,848
  • Joined: 05-May 12

Re: Programmatically add dll references

Posted 11 January 2014 - 12:55 PM

The .csproj files are simple XML files. You can write a short program to replace the references/paths.

I'm still not sold on the idea of changing the projects, though. If your claim is that you need to debug current code, then all you need is the assembly and corresponding PDBs. If you need to debug old code, the same still applies. In either the case of old or new, you would also need the source anyway unless you enjoy looking at IL or assembly.

If you had a build server that held on to current and old builds, you can get everything matched: assemblies, PDBs, and source from all a single location.
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1