Newbie - Memory sharing in COM
-
Hi, I have a doubt regarding memory sharing in a COM object. Background: Recently we shifted to VS2005. Hence the dll written in VC6 is no longer directly useful. I might have to write a COM wrapper to access this dll. The application would be working with huge files and I want only a single copy maintained across my application. The dll should actually read the file and after the error checking send the a pointer of the memory to my application. My question: 1) Is it possible to do it with COM? 2) What would happen if my COM object memory is on a remote server? 3) Does the COM object copy the memory and send it to the requested application or does it just pass the reference. My intention is to maintain a single place of memory where the file data would be read and used. Please let me know how can I achieve this through COM. Any links would be useful. Regards, Arti Gujare
-
Hi, I have a doubt regarding memory sharing in a COM object. Background: Recently we shifted to VS2005. Hence the dll written in VC6 is no longer directly useful. I might have to write a COM wrapper to access this dll. The application would be working with huge files and I want only a single copy maintained across my application. The dll should actually read the file and after the error checking send the a pointer of the memory to my application. My question: 1) Is it possible to do it with COM? 2) What would happen if my COM object memory is on a remote server? 3) Does the COM object copy the memory and send it to the requested application or does it just pass the reference. My intention is to maintain a single place of memory where the file data would be read and used. Please let me know how can I achieve this through COM. Any links would be useful. Regards, Arti Gujare
ArtiGujare wrote:
Recently we shifted to VS2005.
I believe you meant "it's managed code now"
ArtiGujare wrote:
Recently we shifted to VS2005. Hence the dll written in VC6 is no longer directly useful. I might have to write a COM wrapper to access this dll
Do you really need COm wrapper or P/Invoke helps ? http://www.google.co.in/search?hl=en&q=P%2FInvoke&btnG=Search&meta=[^]
S o h a i l K a d i w a l a
To Err Is Human; to Debug, Divine -
ArtiGujare wrote:
Recently we shifted to VS2005.
I believe you meant "it's managed code now"
ArtiGujare wrote:
Recently we shifted to VS2005. Hence the dll written in VC6 is no longer directly useful. I might have to write a COM wrapper to access this dll
Do you really need COm wrapper or P/Invoke helps ? http://www.google.co.in/search?hl=en&q=P%2FInvoke&btnG=Search&meta=[^]
S o h a i l K a d i w a l a
To Err Is Human; to Debug, DivineThankyou Sohail. I am a newbie to COM. When I said we shifted to VS2005 I meant that the application using the dll was previosly written in VC6 and dll too was written in VC6. Now the application has to be written in VS2005 and still use the VC6 dll. My typical use case is: 1) Application send the file name to the dll. 2) dll reads the file at that mentioned filepath and does some file checks 3) if the file is in expected format, the dll returns the pointer pointing to the file data to the applictaion. Can I achieve this using P/Invoke? Regards, Arti Gujare
-
Thankyou Sohail. I am a newbie to COM. When I said we shifted to VS2005 I meant that the application using the dll was previosly written in VC6 and dll too was written in VC6. Now the application has to be written in VS2005 and still use the VC6 dll. My typical use case is: 1) Application send the file name to the dll. 2) dll reads the file at that mentioned filepath and does some file checks 3) if the file is in expected format, the dll returns the pointer pointing to the file data to the applictaion. Can I achieve this using P/Invoke? Regards, Arti Gujare
P/Invoke is a way of invoking unmanaged code from within .NET (a rough description, for more and precise detials see MSDN :) ) If the code you have ported to VS 2005 is still unmanaged code then I don't see any reason why it's not working with your old VC6 DLL. If your application when written in VS2005, is ported and made to be .NET complaint then please read on topics related to 'how to call unmanaged code/dll from within managed code' this will lead you to P/Invoke somewhere http://en.wikipedia.org/wiki/P/invoke[^] http://msdn.microsoft.com/msdnmag/issues/03/07/NET/[^] http://msdn2.microsoft.com/en-us/library/aa446536.aspx[^] Please read about P/Invoke basic and you will be able to decide based on your project needs what to use - P/Invoke or a COM wrapper I hope this helps.
S o h a i l K a d i w a l a
To Err Is Human; to Debug, Divine -
Thankyou Sohail. I am a newbie to COM. When I said we shifted to VS2005 I meant that the application using the dll was previosly written in VC6 and dll too was written in VC6. Now the application has to be written in VS2005 and still use the VC6 dll. My typical use case is: 1) Application send the file name to the dll. 2) dll reads the file at that mentioned filepath and does some file checks 3) if the file is in expected format, the dll returns the pointer pointing to the file data to the applictaion. Can I achieve this using P/Invoke? Regards, Arti Gujare
VS2005 provides several programming languages. I assume that you continue to use C++. In this case you can just use your unmanaged DLL (written in VC6) as you have done before. It's your choice to make the application managed or unmanaged. If you make the application managed (C++/CLI), you may have to take special care when you are marshalling data (e.g. pointers or strings) from your unmanaged code to the managed one. P/Invoke will only be required, if you you change the programming language for your application to a pure managed language, e.g. C#. If you are doing this, I recommend to have a look at http://pinvoke.net/.
Regards, Tim
-
VS2005 provides several programming languages. I assume that you continue to use C++. In this case you can just use your unmanaged DLL (written in VC6) as you have done before. It's your choice to make the application managed or unmanaged. If you make the application managed (C++/CLI), you may have to take special care when you are marshalling data (e.g. pointers or strings) from your unmanaged code to the managed one. P/Invoke will only be required, if you you change the programming language for your application to a pure managed language, e.g. C#. If you are doing this, I recommend to have a look at http://pinvoke.net/.
Regards, Tim