问题
I am in the process of migrating a legacy VB6 app to .Net, however since it is a high-profile business critical application, it is being done piece by piece.
In the interest of improving performance, there is one method which gets hit a lot,thousands of times during the application life, and I was wanting to rewrite it in .Net (C#) to see if the runtime can be improved.
The method in question manipulates ADODB Recordsets. Is there any performance issues I should be aware of or take into consideration since these recordsets will be passed to and from VB6 via COM interop?
回答1:
I haven't done anything specific on this but from my experience with Interop, .NET is very well optimized and usually per interop call to Win API or COM only introduces nano seconds of overhead that is negligible. ADO Recordset will just be treated the same as any other COM objects created on unmanaged heap and under the hood is the IntPtr address that they deal with.
Native .NET framework library and its garbage collector is far superior than whats avaialble in VB. I believe rewriting some of your old VB code in .NET may give you some performance gain more or at least enough to ignore the interop overhead. Best if you equip yourself with a profiler tool and continuosly monitor performance as you migrate the implementation piece by piece.
回答2:
Unfortunately I highly doubt anyone will be able to give you any information regarding your situation that you don't already know. You mentioned that you're passing recordsets to and from VB6 which I can only assume means that you're using the old school ADO COM object from within .Net.
Ick.
So assuming there was no other way I can only conclude I have no idea what kind of technical hurdles you're running into that would force you to commit such an atrocity. I can merely wish you the best of luck.
来源:https://stackoverflow.com/questions/2309383/performance-of-passing-data-between-net-and-com-assemblies