|
Hi,
You need to have the Header file which defines all the
CLSIDs and IIDs.
or
You should #import the TypeLibrary/Dll/Exe of the Component.
Firoz
|
|
|
|
|
I do have the header files however even when I do a #include of the file I still get the error. Now this interface is to a video card that I do not have installed on my machine. Would that be a factor? I know that the CLSID are in the registry and it would make the most logical sense to develope on a machine where the card was located, but I did not have a machine available.
|
|
|
|
|
The problem your having is that the compiler does not know the CLSID and IID. This means that you did not include them. This has absolutely nothing to do with the COM object not being registered, this would only cause a runtime error -> CoCreateInstance returns a class or interface not registered error.
There are two way to use a COM object.
1. Import the type library (.tlb file), just as you would include a header file, e.g. #import "component.tlb" at the top of your .h or .cpp file.
2. Add the _i.c file generated by the components .idl file to your product and include the generated .h file into your .h or .cpp file. This is probably not the way for you as you wil probably not have these files and do not have the source files (read .idl file) to generate them.
|
|
|
|
|
This effect could be caused by a number of different problems.
1. Is the component header file included in a precompiled header? If so, rebuild all should fix it.
2. Do your usage and the defined constants match EXACTLY. I once spent a day of a case discrepency.
3. To find out whats going on. Sprinkle #pragma message statements around and in the include file. They will show you when the include is being recompiled.
e.g.
In the yyy.cpp file
#pragma message("include xxx.h")
#include "xxx.h"
in the xxx.h file
#pragma message("compiling xxx.h")
If your header file contains any ifdefs or pragma once statements (or any other ambiguities, add another message right after the actual definition lines.
#define IID_...
#pragma message("defined IID...")
in
Hope this helps,
Bill
|
|
|
|
|
I feel kind of stupid for asking this, because I haven't had an unresolved external link problem since I began programming three years ago...but here it goes.
I am trying to access the DOM of Internet Explorer. When I call QueryInterface() on other interfaces such as IID_IHTMLDocument, it compiles and works just fine. However, when I do this:
IMarkupServices* pMarkup;
pInterface->QueryInterface(IID_IMarkupServices, (LPVOID*)&pMarkup);
I get the following compiler error:
error LNK2001: unresolved external symbol _IID_IMarkupServices
I've never had an error like this in relation to COM, so I am kind of baffled as to what I need to link to, or do, in order to resolve this link.
Thank-you very much...
|
|
|
|
|
Do a find-in-files in the LIB directory for that symbol, and you'll find that it's in uuid.lib.
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork ID - 100.10414 AcidHelm
|
|
|
|
|
Hello everyone,
I am new at COM. I want to implement a COM object that throws _com_error objects as error. How can I implement such a functionality in my COM object.
Busy Bee
|
|
|
|
|
Hi Busy,
Sorry, but the COM standard only allow COM-errors, if you want it to throw a generic error, you can write a wrapper for your COM-module, that catch a com error and then throw an error.
/_henrik
Henrik Sternberg,
Cambridge Technolgy Partners Central Europe
www.ctp.com/ce
|
|
|
|
|
Are you working with ATL?
Cheers
Carlos Antollini.
|
|
|
|
|
Look at IErrorInfo in combination with HRESULT. There is plenty of info in MSDN.
Michael
|
|
|
|
|
if you are using ATL then you can use
the method Error to throw the exception, this will be caught in a _com_error catch
e.g.
instead of returning S_OK;
do the following
return Error(_bstr_t(ErrorDescription).copy(), IID_IObj);
|
|
|
|
|
Thank you every one. I have figured all that out.
The actual class should have an implementation of ISupportErrorInfo.
Thanks everyone again.
|
|
|
|
|
I need implement com add-ins in my application, just as Visual C++ 6.0 do. so my client can add something more in my application with add-ins. can you give me some advices, thanks!
|
|
|
|
|
|
I developed an ATL server from which I throw _com_error exceptions with
return Error(szMyDesc, IID_IMyObj);
On the server side I use
try
{
//...
}
catch(_com_error& err)
{
//...
}
Everything is fine and I get my error messages when the server is created in debug mode. When I create the server in release mode and an error should be expected I get on the client a crash with the message:
the instruction at "0xhhhhhhhh" referenced memory at "0x00000000". The memory could not be "read".
If you have any idea what is the reason please help me as soon as possible.
Thanks!
|
|
|
|
|
Sounds like an uninitialized variable somewhere. That is almost always the cause for the symptom you describe. You can also try turning off optimizations, changing thread libraries and stuff like that. But I reiterate, uninitialized variables are nearly always the cause of bugs that only show up in release builds.
|
|
|
|
|
The error seems to happen in function _com_issue_errorex():
if (FAILED(_hr))
_com_issue_errorex(_hr, this, __uuidof(this));
but I still don't know why? In debug mode everything is fine!
If you have any idea please help me!
|
|
|
|
|
I have written two applications one of which is wizard style dialog based app and the other is an SDI. It turns out that what was needed was the wizard to be started from within the SDI as well as a stand alone app. I thought that Automation was the way to go and so far I have solved half the problem. The Wizard can now be started from within the SDI app and I can set some initial values. What I now need is for the wizzard to tell the SDI that it has completed, and that either the Wizzard tells the SDI the file name of the newly created file or that the SDI shiould now query the Wizard for said file name.
Any help would be great
Cheers
AndyC
|
|
|
|
|
You need to have your Automation server fire an event back to the client. This is done through a connection point. Lookup IConnectionPoint on MSDN for specifics. There are some good articles there. The wizards can help set it up.
Its not really very hard to set up, if you know have the COM object when you are writing the code. I trid to use them in my own project, but I never made it work. I had to set mine up dynamically since the client accesses an unknown number of COM servers.
Hope this is helpful,
Bill
|
|
|
|
|
I have tried to Impliment connection points within my automated server exe. I did this by using the wizard to create an ATL "Simple Object" with the "Support Connection Points" options enabled. I added the fuctions that I required to fire and Implimented Connection Points with the revalent class. When I try to make a instance of this object it failes because the object is not registered. How do I get to register this new object, seeing my app is not a com dll or com exe the regsvr32 function also fails.
Best Regards
AndyC
|
|
|
|
|
i'm doing my college assignment call plug-in application,
my main application is using VC++ with Automation support then i need my plug-in application(in VB (.EXE also)) to call VC++ method, therefore in VB i just write the code:
dim a as object
set a = CreateObject("MyCOMApplication.Application")
this work fine, but what if i open my "MyCOMApplication" already, then in VB i create it once again, then it became 2 same application with different address,how can i create the object in VB but just get the reference on that COM? but not re-create it? i really hope someone can help me, because the assignment due date is pending .. thanks for helpness, i will appreciate
|
|
|
|
|
I'm not that up on VB, but I think GetObject does what you want. If it fails, then use CreateObject.
Thanks for the help,
Bill
|
|
|
|
|
To make all clients talk to the same instance
of your COM Server, you can use the Macro
DECLARE_CLASSFACTORY_SINGLETON(...)
in your COM class.
Firoz
|
|
|
|
|
thankz Firoz , but can you tell me what's the different between this function from CCOMCOClass and RegisterActiveObject ?
|
|
|
|
|
Hi, i've got this com object created with Atl Wizard, then I implement a connection point, and fire the event with Fire_Alarm(). Register my client to that event with AtlAdvise, but when firing the event, my client doesn't notice.
The same client with an old atl com objects version (the proxy header created with Atl Proxy Generator) works fine, so I guess it might be a server problem.
I've debugged the server, and the connection between the client and the event is made (the number of connections is 1). Someone told me is a bug in the code generated by the wizard, anyone has any idea?
kike
|
|
|
|