|
Hi,
My Program is supposed to run contineously so i need to concern about memory management with COM.
Here is the scenario,
I created a COM Object using CreateInstance()
using that COM object i am creating another object using QueryInterface.
Here is my question.
1. if i am releasing the first object which i got using CreateInstance, then subsequently the objects which are created using that will be removed from memory right?
Since if i call release for object got using QI causing crash.
But i am fine if i release the first object, but i am afraid this would lead to a memory leak issue.
Kindly Advice!
Thanks in advance
-Ganesha
Thanks a lot
|
|
|
|
|
Unless the second object is aggregated in the COM sense, i.e. it's a server that lives inside another server, thou-shall-not-create-objects-with-QueryInterface!
QueryInterface has a well-defined purpose and functionality: you ask a COM object you already have an interface to for another interface, the object returns that interface if it implements it and fails with E_NOINTERFACE if it does not implement the requested interface.
If such functionality is desired you should create an interface function that clearly says it will create another COM object.
ganesa moorthy wrote: if i am releasing the first object which i got using CreateInstance, then subsequently the objects which are created using that will be removed from memory right?
Not if the object still has clients, i.e. it's reference count has not reached zero.
It looks to me as you two objects are too tightly connected.
If you make them available in the same server (COM object) but perhaps reachable from different interfaces, you can use QueryInterface correctly.
Another alternative is to make the two objects less connected and actually have two different COM objects.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Dear All
I have very simple question what is difference between COM and COM+
What are the uses of these both technologies
Thanx in advance
Sajjad
|
|
|
|
|
I think asking Google will be useless [^], in you case.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
COM+ is a refined version of COM. COM+ also supply a number of service to component running under Windows, including
1. Role-based security
2. Object pooling and reusability
3. Queued components for asynchronuous calls
4. Transaction processing
5. A publish-and-subscribe events model
Ali Zishan
London
|
|
|
|
|
Hi,
Basically COM+ = COM + MTS (microsoft tranaction server).
COM+ is built using Aspect Oriented Design.
Aspect oriented design are like some aspects(security, pooling etc) that you can use from the framework and not required to progrm by yourself.
this is what COM+ provides once you create a COM+ application and register you componet with that.
^-^
@|@
- redCat
|
|
|
|
|
Hi,
I am having a COM Component and i am accessing the com using VB client.
In Com function i am using SysFreeString, i am calling a function inside COM DLL by passing a string argument from vbclient.
After usage i am calling SysFreeString inside the com function.
The above mentioned functionality works on several machines and fails(VB client crashes) in one machine.
I removed the SysFreeString function call from the failing machine, and now it is fine.
Can anyone tell why this happens so strangely ? Anyway we need to call SysFreeString to free up the memory.
Kindly guide me!
Advanced Thanks,
Ganesha
Thanks a lot
|
|
|
|
|
Hi,
I can't say why one machine behaves differently, in fact I would say if you can fix the code so it works on all machines you don't need to know.
All my VB -> COM was done in Visual Studio 6 and used IDL rather than attribute based which yours may be but the issues should be the same. What IDL attributes are applied to the string being passed, an [in] or [in,out] or possible [retval]?
As you are freeing the string in the .dll, I'm assuming its an [in]?
|
|
|
|
|
Hi,
[in], [out], and sometime [out,retval]
Advanced Thanks!!!!
Thanks a lot
|
|
|
|
|
That seems right, I think VB passes strings by reference so it has to be [in,out]. As there is an out] part, VB expects a string to be passed back (out) and is probably deleting this according to some garbage collections algorithm - but you've already done it in the dll. I think not deleting it in the .dll is OK here - you would only do this if it were an [in]. You could delete it in the dll but only is you then assign a new string to it for the [out] part - it's this [out] part that VB is expecting and deleting.
|
|
|
|
|
After deallocating with sysfreestring, are you providing a new value with sysallocstring ?
|
|
|
|
|
As a part of my project I would like to develop an activex control, whose functionality should be similar to passing vlc.exe(exe file of the vlc player) and the name of a encoded video stream as inputs to the command line. Please provide me with any links to a similar project.
Thanks in advance
|
|
|
|
|
I am currently trying to learn the basics of Interoperation in .NET. As a step towards that goal I would like to create my own COM DLLs to be imported and used in managed code.
I would like to know a way to get COM DLLs as output in VB or C++ with free tools. Any recommendations?
|
|
|
|
|
I hope you have a sense of humor,...
You can do this in Assembly Language (and, it's insanely fun). OK, I'm torturing you,...it's a pain in the ass (but, definately possible).
I would recommend Visual Studio (because it has a number of great Interoperability Tools, and comes with the latest NET Framework). The Standard Edition is somewhere between $100 and $150. If you plan to do alot of COM, it's a good investment.
|
|
|
|
|
I have defined a struct type in IDL as follows
typedef struct tData
{
int i;
int j;
tData()
{
i = 0; j = 0;
}
}MyData;
Getting error as follows.
error MIDL2025 : syntax error : expecting a type specification near "tData".
|
|
|
|
|
Hi,
I am having a COM DLL which is working fine in three Windows 2003 installed machines.
But Fails in another machine which has same windows 2003.
What could be the possible cause of this ?
Advanced Thanks ,
Ganesamoorthy
Thanks a lot
|
|
|
|
|
Is it possible to get the write speeds supported by a drive (media device) using IMAPI interfaces. I have tried with the "get_SupportedWriteSpeeds" and "get_SupportedWriteSpeedDescriptors" API's of "IDiscFormat2Data" inteface. But both of them returns speeds specific to a media (CDR / DVD-R etc) inserted.
SKMukherjee
|
|
|
|
|
Hi Experts,
I am new to COM programming. (Component Object Model.)
After learning some theory behind COM, I am wondering
Why COM when every thing is possible using DLLs which exports C++ classes.
Or
What is possible only in COM and not possible in C++ DLLs.
Could anyone explain?
Thanks in advance
cheers
Varghese Paul
|
|
|
|
|
Hi there. This article might be useful I believe. What you suggest is treated in the "C++ Naive Approach: Exporting a Class" section, whereas the COM approach is similar to the described in the "C++ Mature Approach: Using an Abstract Interface" section.
In short, there are many problems with simply exporting classes from a DLL. If you change a dependency, most likely you'll have to recompile them all. You have to have the same compiler and even compile with the same settings. A nightmare if you're planning on distributing your components to other people.
Cheers.
Stupidity is an International Association - Enrique Jardiel Poncela
|
|
|
|
|
If you can get a copy of Don Box's "Essential COM", I would recommend it. It explains the evolution of COM clearly and thoroughly (but, it's fairly abstract reading).
There are two basic concepts that are the core of COM:
(1) COM objects are binary-compatible with COM objects and methods written in any other programming language (the compiler vendor implements this feature). This means that you can call CoCreateInstance for any existing, valid COM object (written in any language) and use an instance of that COM object and its methods in an your external program, just by linking to the existing DLL.
(2) COM Interfaces cannot be altered once they are published. This is an attempt to eliminate what is known as "DLL Hell". This occurs when a COM component is re-written and re-compiled, changing some signatures of object method calls and causing existing compiled clients that utilize these new methods to fail when a type or method executes with an incorrect memory allocation.
There is A Huge Number of Excellent COM Tutorials Right Here at CodeProject[^]
An Excellent Two-Part Beginner Tutorial Series about COM is Introduction to COM, What It Is and How To Use It[^] and Part Two, Behind The Scenes of a COM Server[^], by Michael Dunn is a good place to start.
|
|
|
|
|
This may not be the correct place to ask this but I have a third party dll file that was created for VB6 (The examples you can download are for VB6). Is there any way to update this file to work with Visual Studio 2002? The dll holds the functions to talk to the third party device. Thank you
<edit> I talked with someone at the company and they had given me the VB6 version not the VS version.
If you can’t have fun at work, then why go to work?
modified on Friday, December 12, 2008 10:10 AM
|
|
|
|
|
It's difficult to try to imagine what it is that you are actually trying to do. Are you asking if Visual Studio is capable of disassembling a compiled DLL and altering it (to what specifications?), or, are you asking if you can somehow link to the compiled DLL and use it for your nefarious purposes? OK, I'm kidding,...but, you should elaborate a little about what it is you are actually attempting to do.
...and, what do you mean by "dll not recognized"?
Suggestion: use Dumpbin to determine what functions the DLL exports,...that's probably what you want to know, if you are attempting to use the functionality of your third party DLL.
|
|
|
|
|
I should have edited the message. I finally got a hold of someone at the company that understood what was going on. The dll I was told to use was for VB6 and not VS. They were able to point me to the correct dll. Thank you for taking the time to answer.
If you can’t have fun at work, then why go to work?
|
|
|
|
|
Hi,
If you have Third party COM which is developed in VB6, and you wanted to use this COM in Visual Studio then you need proxy to use Unmanged COM. In .Net there is Runtime callable wrapper (RCW) use to access any unmanaged COM into .Net platform. There is an exe (tlbimp.exe)in .net command prompt to import any unmanaged COM into Managed COM.
Ali Zishan
London
|
|
|
|
|
Hi all,
I am trying to build an application for Windows CE 5.0 device, using PI method to work with the unmanaged library here, the code written for regular windows application works fine but when the same code is used for Windows CE 5.0 device application i am getting an compiler error say
'System.Runtime.InteropServices.Marshal' does not contain a definition for 'StringToHGlobalAnsi'
Can anybody help me in resolving this problem. Also is there any alternative way like MarshalAs attribute to achieve the same.
Regards,
Geetha
|
|
|
|