Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Hi All,


In my Application, comprising many COM-Dll's, I had added new class/interface/method, obviously, since, IID-CLSID changes, we need to register the Dll "abc.dll" using RegSvr32.exe "abc.dll", by closing the instance of Application.(pre-requisite) and replacing the newly registered dll's with the old one.

But my query, is it possible to effect the above scenario when Application is running(without the application been closed). ?

my understanding is, the Dll (Com-dll) is loaded at predefined base address in process address space, and when it is subjected to addition of interfaces/method, such dll needs to be un-loaded and re-loaded again to effect the modified change.

Is it feasible to add interface/method to COM-Dll for running instance of Application ?

Details:

VS 2008 IDE, Windows 7 o/s.

Thanks in Advance,

Regards,

VishaK_90
Posted
Comments
Sergey Alexandrovich Kryukov 10-Apr-13 10:31am    
Why?
—SA

1 solution

As a quick answer, I would answer: better forget it.

However, there are couple of remote possibilities related to System.Reflection.Emit. You can generate (emit) a whole assembly during runtime and use it. Alternatively, you can add a separate method during run-time, convert it to a delegate instance and call during runtime. Please see:
http://msdn.microsoft.com/en-us/library/system.reflection.emit.aspx[^],
http://msdn.microsoft.com/en-us/library/system.reflection.emit.dynamicmethod.aspx[^].

Those approaches are very advanced and are used in some very special cases. One of such models is serialization, which is agnostic to the data types. If the code always uses System.Reflection to dig into each type and serialize it, it results in low performance, only acceptable for pretty small object graphs and volume of data. With System.Reflection.Emit, the reflection is performed only once per type, to serialization code is created on the fly and later reused.

In all those techniques, just the debugging of emitted code is a problem. And the emitting of the code… as a bare minimum, it requires good knowledge of CIL and good understanding of CLR functioning.

So, I would not give you more detail before I can understand your goals and see that you can go this way. Chances are, you can devise much simpler architecture. Something tells me that you don't yet have the elaborate conception of adding the code dynamically and its purpose.

—SA
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900