?
Solved

How can i upgrade referenced components!??!!

Posted on 2005-03-09
24
Medium Priority
?
198 Views
Last Modified: 2010-05-02
Hi, does anyone knows how can i upgrade referenced components through the same application?!?!

What i mean is that i have implemented a VB Project, 3 dll and 5 ocx. ok?!?!
The VB Project (EXE) has references to all these 3 dll and 5 ocx. if i make some code changes to my components
i need a way to make my application (the VB Project - EXE) to upgrade somehow all these components (upgrade its self).

But since they are used from my application, it is logical to get an error when i am trying to unregister and then register them.
How can i somehow unload the references i want and then load them again.. is there a way?!?!?!

p.s.: Building another application that upgrades these components is not an option!:P

Thanks in advance..!
0
Comment
Question by:satanakos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 7
  • 4
  • +2
24 Comments
 
LVL 8

Expert Comment

by:fatalXception
ID: 13494056
If you have added references to these components in your VB project, then it shouldn't be an issue, as long as you chose "Binary Compatibility" when you built the components.
Also VB will automatically register dlls and ocxs for you when you build them on your system.
You shouldn't need to "upgrade" your VB program unless you have added new functionailty to the dlls thatw as not there before. In which case, you need to rebuild the EXE anyway.

Or did I miss the issue?
0
 

Author Comment

by:satanakos
ID: 13494079
Yeap... you missed it:P

I need my clients get the upgrade components.. meaning that i don' t want to send them everytime i change something an .msi

So if i make a code change in one dll i don't want to run in every client i have (there may be 40 clients that run this exe) paste the new one and then register it.
I want to do it through my application. But to do that i must somehow bypass/unload/disable some of my references to do that.
0
 
LVL 8

Expert Comment

by:fatalXception
ID: 13494145
OK, now I get you.
But I cannot see a way that you can upgrade files that are in use whilst this EXE is running, without having a helper process. Either you can overwrite the files, or you can't, if you are saying that you've tried overwriting the files and get access denied, then you can't. You might consider using COM Interfaces so that the actual target dlls are abstracted from the app. Maybe I'm wrong on that one.

If they are compiled using binary compatibility, then you ahouldn't need to re-register them, because they are already registered.
If there is new functions, etc, then you will have to upgrade the EXE anyway.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:satanakos
ID: 13494291
Ok i'll check the COM Interfaces..

I was hoping that i can bypass the helper process but ok!:(

thanks anyway!
0
 
LVL 8

Expert Comment

by:fatalXception
ID: 13494316
no problem, I'm sure some of the other lads will have some helpful input too.
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 13494514
FatalXception,

Adding new functions does not break compatibility or am i going loopy.  I believe only changing existing interfaces (i.e changing method signature) will break compatibility

Satanakos,

Whether or not the components are compatible with those already on user's PC AFAIK you can't overwrite a referenced component.  Even with .mis a reboot will be required.  Are you saying you don't want to stop the app while updating the dll's and ocx,s?  One possibility will be to use Visual basic Extensibility object model and in your app provide a user interface i.e menu or button (or even listen to a folder changes) so that when new components are put into a particular folder you remove references from your project and replace the old component file with the new (and register if compatibility was broken)
0
 
LVL 8

Expert Comment

by:fatalXception
ID: 13494605
gbzhhu, what I meant was, if you're just upgrading the code in the existing functions an objects, it's fine.
But if you were adding en extra functions and classes, you would need to recompile the exe to use these.

In terms on interfaces, you can't change them, they are a fixed contract. You can add new interfaces to provide new functionality on top of the old, but you still would have to upgrade the .exe to use them.

Also, if you compile a DLL and do not set it's compatibility to Binary (say you leave it as project) then every change you make to the dll requires you to recompile the application as well. (even if you only change the internal function code and leave the signature the same), of course you can get around this by using CreateObject but that requires new dlls to be re-registered.
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 13494727
fatalXception,

Yes, that is exactly how I see it.  In fact, I questioned my sanity and just finished testing it before i read your post.

So now if satanakos has changed code in a way NOT to break compatibility (internal code change) and wants that applied to his client's PC he/she will have to update the dll or ocx on the client machine.  If he/she broke compatibility then it is the same scenario, components should be updated.  I think the question is how can it be done while the app is running.  Although I did it in VBA Excel I am in doubt as to whether VB Extensibility will achieve it as it relies on VBIDE whereas we are talking about an exe here.  To be honest I can't see a way without any manual intervention and app stoppage
0
 
LVL 8

Expert Comment

by:fatalXception
ID: 13494778
gbzhhu , I agree.
 Although my sanity has been returning a NULL reference for some time now, I had to read my own post twice before I sumbitted it ;p
0
 
LVL 7

Accepted Solution

by:
Smallint earned 750 total points
ID: 13494893
Hi satanakos,

One possibility to do what you want is to create and mantain all objects in a server, intead of on each client through DCOM.

Steps are:

* Compile your DLL with Server Files option checked. It should create a tlb and a vbr file. This files will be needed for registration on client machines.

* In your server, install your dll and create a server application in Component Services and create a component inside with your dll.

* On client machines

Automatically:

With setup wizard, do not include your dll in your exe's package, use tlb and vbr instead. In some point of process you will see you can write server and protocol. If you left it blank you will be asked for it during client installation.

Manually:

e.g. in a cmd window type:

CLIREG32 Yourdll.VBR -t Yourdll.TLB -s <YourServer> -d

This registers type library on the client machine to use DCOM to create the object on YourServer machine.


Take a look at this nice article... http://www.vbcity.com/page.asp?p=chapter&f=books-wrox-vbcom


Cheers
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 13495357
SmallInt,

How is this going to work for OCX's?

And if you are going to use COM+ why not just export the Proxy from COM+?
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 13495384
You CAN replace DLL's & EXE's while the app is running (sort of).  You can't overwrite the old file, but you CAN rename it, and then put down your new file.  The app will continue to use the old code until it is unloaded from memory, and will use the new one when next loaded.  I do this with EXE's all the time, I presume it will aslo work with DLL's
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 13495409
BTW, this only works if you A) maintain binary compatibility, or B) replace all dependent components.  The folks about are right about binary compatibility, if you maintain compatibility, you can plop down new components without re-registering them
0
 

Author Comment

by:satanakos
ID: 13495419
yeap but if i have new methods and properties i won't see them till i register the component
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 13495622
>The app will continue to use the old code until it is unloaded from memory

If this acceptable then why not stop app (same as unloaded from memory)?

0
 
LVL 8

Expert Comment

by:fatalXception
ID: 13495623
satanakos, you are correct but if there are new methods and properties, you would have to recompile and redistribute the exe anyway in order to use these new methods, etc. (unless you have managed to get function pointers working in VB ;p) so it would be "much of a muchness" to redist the dlls and ocxs at the same time anyhow.

SmallInt's suggestion will work, for the OCXs as well but I'm not sure you want to use DCOM if you have that many items in the project.
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 13496263
fatal,

Can you explain to me how OCX's are going to work via DCOM, this is something I am not familiar
0
 
LVL 8

Expert Comment

by:fatalXception
ID: 13496402
afaik it's the same for an AX control (OCX) as for a DLL or EXE, you can store it remotely and tell the client to create it on a different machine. Of course it still runs locally, kind of like when you visit a webpage and the AX control gets installed.
So that's whay it might not be a good idea because the binary will have to be downloaded the first time you try to use it, could cause all sorts of network bandwidth issues.

**I coud be wrong, though, I shoulda checked that last comment tbh.**


0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 13498028
The way I was looking was:

A component is either local or remote

Local - let's ignore this one - no complications

Remote

Remote components are either in process (dll, ocx) or out of process (ActiveX.exe).  My believe is that remote in process components need a host to run.  That is why we had MTS and now COM+.  I don't know of a way that you can just stick a dll in remote machine and just access it from a client without a hosting environment.  ActiveX.exe don't need a host as they run in their process space.  You just pass a second parameter to CreateObject specifying the server.

OCX are in process but because of their nature they cannot be accessed remotely (I am not really sure when it comes to Web development and Web controls), they are a user interface and therefore should be in the same machine as the client code.  You cannot put OCX into COM+ as a component

This is how I see things but to be honest I can be very wrong and if anyone sees anything wrong or misunderstood I'd like to be corrected

I hope to learn something new as I always do

Ta



0
 
LVL 8

Expert Comment

by:fatalXception
ID: 13498244
as far as OCX goes, OK I have never actually tried this but I think that maybe on a Windows app situation it won't work, will make an interesting experiment though.

satanakos, are we helping / hindering at this point?
0
 

Author Comment

by:satanakos
ID: 13503451
Yeap, i sort of found a solution by removing all the references of the components i needed to upgrade, and i am starting declaring all the variables to these components with CreateObject...
0
 
LVL 8

Expert Comment

by:fatalXception
ID: 13504139
Cool let us inow how it works out.
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 13504481
That is very interesting.  Waiting to see how it works
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 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