Solved

Registering multiple versions of the same dll

Posted on 2013-06-08
10
525 Views
Last Modified: 2013-06-29
I am trying to have two versions of the same dll running on the same machine, as I described in my last question here. As you can see from that question, I accepted the first answer, which I thought had solved my problem. But as it turned out, I hadn’t tested it out enough. The ‘If’ statement did change the GUID for release, but it didn’t handle a different factor.
      Visual Studio always unregisters the old version of your dll before registering the new one, and it seems to keep track of GUID changes, at least in a limited scope. For example, if you have an assembly that is registered for COM interop, and you change the GUID, Visual Studio knows to unregister the old GUID instead of trying to unregister the new one which obviously hasn’t been registered yet.
      This creates a problem, since I want both versions of the dll to be registered at the same time. I want to compile for debug, then compile for release (while keeping the debug version registered and working) and then go back to compiling for debug (while keeping the release version working). So I need Visual Studio not to unregister the old GUID when the ‘If’ statement changes it.
0
Comment
Question by:BROOKLYN1950
  • 5
  • 3
  • 2
10 Comments
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 39233614
Either explicitly set the dll path or change the search order
http://stackoverflow.com/questions/2119539/visual-studio-how-to-set-path-to-dll
0
 

Author Comment

by:BROOKLYN1950
ID: 39233758
I’m not sure I understand your answer. The file path of the dll is not the issue I’m running into. By default the dll is compiled to the “…\Debug” directory when compiled for debug, and the “…\Release” directory when compiled for release. I can have both files on the machine at once easily.
      The problem happens when I change the compiler from debug to release. If I compile for debug and then compile for release, Visual Studio removes the debug version from the registry (or wherever the list of COM components is kept). The file is still there, but it doesn’t show up in Excel since it is no longer registered as a COM component.
      The final result I need is to have both versions (debug and release) to show up in the Excel references window at the same time, so I can pick either one (i.e. my Excel file in development uses the debug version, while live and in use Excel file uses the release version).
0
 
LVL 78

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
ID: 39233808
Thanks for expounding on the question.. I don't think you can do this.. The way I'd test it is via a virtual machine..
0
 
LVL 32

Expert Comment

by:sarabande
ID: 39234242
to achieve what you want you need all the registry informations stored to be completely different. all guid's of release and debug have to be different. the names of the dll's can be same as far as they were linked by import library to the executables. if they were used from Excel only the registration as separate COM controls is important.

Sara
0
 

Author Comment

by:BROOKLYN1950
ID: 39238491
The dll will be used only from Excel, when you say a separate COM control, does that mean they have to have different names?
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 32

Expert Comment

by:sarabande
ID: 39241144
i don't know very much of excel. so i can't say whether excel could have the same name for different GUID. but I think, yes, you should add a D suffix to the name of the debug control.

Sara
0
 

Author Comment

by:BROOKLYN1950
ID: 39242962
The problem here doesn't seem to be Excel. I've gotten Excel to use two versions of "the same dll" by making a copy of the project's folder and changing the GUID of copy's assembily. Both assemblies show up in Excel (with the same name but different file paths).
      That is not very workable since I would have to make a new copy of the project and change the GUID in the copy each time I wanted to deploy a new 'live' version. I'm trying to find a way to do it from within the same project.
0
 
LVL 32

Expert Comment

by:sarabande
ID: 39243640
a dll is a file and it is not difficult to using two dlls located in different paths. a COM control has a unique identification in the registry. so you need two controls in registry for your case beside you could put them to a manifest.

debug and release have a different configuration. it is not impossible to define register information for debug and release differently such that you got two controls.

Sara
0
 

Author Comment

by:BROOKLYN1950
ID: 39245153
I'm aware that COM components have unique identifiers in the registry separate from their file paths. That unique identifier is the GUID (Globally Unique Identifier). I can change the GUID for different configurations (as shown in my previous question). I just need to be able to change it without having Visual Studio remove the old one.
      I don't need Visual Studio to do an extra action, I need it not to do an action that it is already doing. Both versions of the dll would work if Visual Studio didn't un-register the old GUID before registering the new one.
0
 

Author Closing Comment

by:BROOKLYN1950
ID: 39287187
After a lot of searching and testing, I decided to use a separate development environment, as it seems that this really can't be done. Oh well...
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now