Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I created a dll called A.dll and strong named it with version 1.0.0.0 and compiled it.Then I copy pasted this A.dll into a local folder. Then I increased the version of A.dll to 2.0.0.0 and compiled to get new A.dll.
Then again I tried to place the latest dll into that local folder, expecting both versions should exist side by side as it does in GAC. But I cant..
Please tell me how to achieve that?
(I dont want to use the GAC)
Posted 16-Feb-13 1:00am
Comments
Richard MacCutchan at 16-Feb-13 6:14am
   
You cannot have two files with the same name in the same folder.
Logi Guna at 16-Feb-13 14:15pm
   
Why not put v2.0 dll in different folder?
It's simple, just add AssemblyResolve event for v2.0 dll.
See http://www.codeproject.com/Articles/310675/AppDomain-AssemblyResolve-Event-Tips
Sergey Alexandrovich Kryukov at 17-Feb-13 1:10am
   
OP commented:
 
Yes it is a better solution to have the two assemblies in subfolders v1.0 and v2.0 ... I was thinking if I could manage to have them in the same folder some how ...
Sergey Alexandrovich Kryukov at 17-Feb-13 1:11am
   
Of course you can do it, but you are thinking in wrong direction. The best you can do is having only one version.
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Lets say GAC is a special folder that keep track of files not just by name but by version too. Thus, it allows assemblies of same name but different version.
 
Local folder does not care for version. If it has files of same name, it would not allow to copy.
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 16-Feb-13 20:34pm
   
I think OP needs much simpler answer at this moment, not a solution. By the way, using GAC is not an acceptable (more exactly, not good enough as it would require complex uninstallation) solution for assemblies used only in one product. The root problem is some versioning and versioning policy.
Please see my answer. It the problem can be formulated more to the point, we might suggest a solution.
—SA
debdeep Bhattacharyya at 16-Feb-13 23:49pm
   
yes GAC shouldnt be added with just any dll just because some local exe needs its various versions.
Sandeep Mewara at 17-Feb-13 0:02am
   
I have not suggested to use GAC. Please re-read my answer. I have used GAC to compare and make OP understand what is happening and the reason why he cannot put two different version dll in a normal folder.
Sergey Alexandrovich Kryukov at 17-Feb-13 0:18am
   
Sure; I know. I just didn't express myself clearly. My not about GAC is not related to the question. I only wanted to confirm OP's idea about not using GAC. My idea was just to dismiss two identically named files in the same directory. This is all deserved by this question. Everything else might come only after OP's clarification.
—SA
Sandeep Mewara at 17-Feb-13 0:20am
   
Sorry SA, my comment was directed to debdeep who answered your comment. I did got your point first time. OP looked like novice to even understand why same name assembly cannot be in a folder so I had to use GAC example.
 
Sergey Alexandrovich Kryukov at 17-Feb-13 0:25am
   
No, I'm sorry for my confusion.
 
I see, please see further discussion of Solution 2. Unfortunately, OP clarification only clarifies that OP holds the same line thinking over some suggested ways of solving the problem instead of the problem itself.
—SA
Sergey Alexandrovich Kryukov at 17-Feb-13 0:23am
   
Please see further discussion below Solution 2. I clearly explain now what's the problem.
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You cannot have two file with identical names in the same directory, by definition. And you never ever need it.
 
If you explain your ultimate goal, you might have a chance to get some practical advice. You apparently experience some versioning problems with your product. But them address this problem instead of putting unnatural requirements to file systems and asking the questions based your (correct or wrong) understanding of how to solve the problem. Ask about your problem itself.
 
—SA
  Permalink  
Comments
debdeep Bhattacharyya at 16-Feb-13 23:47pm
   
My problem:
I have two executables they are located in the same folder and uses same dll, one exe calls the other during its execution and looks for it in local folder. I have no control over code of those exes.
Now I want to replace the dll with newer version as I have source code of that dll, however I want one exe to use the older version and another to use the newer version.
Sergey Alexandrovich Kryukov at 17-Feb-13 0:22am
   
You again asking not about resolution of some problem, but about your suggested way of doing things. Your way is wrong. We should not talk about "two executables in the same folder", not about "replace DLL with newer version". Those are all misconceptions. We should talk about why doing all that, starting from your original, ultimate goals.
Perhaps you should learn about assembly resolution (and at this point you should dismiss the idea of using the same directory; why?!); or you should think about general problem of versioning and compatibility. But it's more likely that you simply need to unify versions.
 
—SA
Sandeep Mewara at 17-Feb-13 0:30am
   
Totally agree with SA.
debdeep Bhattacharyya at 17-Feb-13 0:28am
   
can u suggest some article(easy to understand) that should lead me to light?
Sergey Alexandrovich Kryukov at 17-Feb-13 1:13am
   
You can do search by these keywords.
 
I suggest you do completely different direction: how to properly support version. Supporting two different versions for different applications of the same product is not wise. If you lean some techniques (eventually you will), it will only bring your away from right approach.
 
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Mika Wendelius 261
1 Abhinav S 155
2 Peter Leow 140
3 Sergey Alexandrovich Kryukov 125
4 Kornfeld Eliyahu Peter 115
0 Sergey Alexandrovich Kryukov 8,593
1 OriginalGriff 6,536
2 Peter Leow 3,727
3 Zoltán Zörgő 3,456
4 Richard MacCutchan 2,417


Advertise | Privacy | Mobile
Web03 | 2.8.150123.1 | Last Updated 16 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100