Click here to Skip to main content
15,916,293 members
Home / Discussions / COM
   

COM

 
QuestionCOM object with CLSID {845FB959-4279-11D2-BF23-00805FBE84A6} is either not valid or not registered. Pin
Mohamed Jaffar Sagir27-Dec-05 0:21
Mohamed Jaffar Sagir27-Dec-05 0:21 
AnswerRe: COM object with CLSID {845FB959-4279-11D2-BF23-00805FBE84A6} is either not valid or not registered. Pin
PhilWilson4-Jan-06 6:56
PhilWilson4-Jan-06 6:56 
QuestionCannot open include file: 'Wbemidl.h': No such file or directory Pin
abhiramsss26-Dec-05 23:32
abhiramsss26-Dec-05 23:32 
QuestionProblem in Chinese Traditional Charset.. in com addin Pin
Ganesh_T26-Dec-05 18:29
Ganesh_T26-Dec-05 18:29 
QuestionDirectShow: Getting the window handle of a panel Pin
Ramow26-Dec-05 5:20
Ramow26-Dec-05 5:20 
QuestionOut of Proc exe and Win NT service Pin
misha_grewal25-Dec-05 20:06
misha_grewal25-Dec-05 20:06 
QuestionEnterprise services Pin
psantoshkumar25-Dec-05 19:26
psantoshkumar25-Dec-05 19:26 
Questionhelp on ATL COM first-chance exeption problem Pin
hardworkboy22-Dec-05 15:23
hardworkboy22-Dec-05 15:23 
Dear all,

I am using EVC4 to try a ATL COM program. Some source codes are as following. I got a first-chance exception problem. Can anyone help to tell me the reason? Can we test the .dll using some tools like the ActiveX Control Test Container?

ConnectionCom.cpp

#include "stdafx.h"
#include "resource.h"
#include "initguid.h"
#include "ConnectionCom.h"

#include "ConnectionCom_i.c"
#include "Add.h"


CComModule _Module;

BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_Add, CAdd)
END_OBJECT_MAP()

class CConnectionComApp : public CWinApp
{
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
};

CConnectionComApp theApp;

BOOL CConnectionComApp::InitInstance()
{
_Module.Init(ObjectMap, m_hInstance);
return CWinApp::InitInstance();
}

int CConnectionComApp::ExitInstance()
{
_Module.Term();
return CWinApp::ExitInstance();
}

/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE

STDAPI DllCanUnloadNow(void)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE;
}

/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type

STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _Module.GetClassObject(rclsid, riid, ppv);
}

/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry

STDAPI DllRegisterServer(void)
{
// registers object, typelib and all interfaces in typelib
return _Module.RegisterServer(TRUE);
}

/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry

STDAPI DllUnregisterServer(void)
{
_Module.UnregisterServer();
return S_OK;
}

ConnectionCom.idl:

import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(4B15EACE-A33D-4E53-B815-5486B457AEDF),
dual,
helpstring("IAdd Interface"),
pointer_default(unique)
]
interface IAdd : IDispatch
{
[id(1), helpstring("method Add")] HRESULT Add(int a, int b);
};

[
uuid(7D8286AC-AA29-48B1-A3A9-9394D54EBE22),
version(1.0),
helpstring("ConnectionCom 1.0 Type Library")
]
library CONNECTIONCOMLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");

[
uuid(1B58E8FD-6D14-45BB-88F1-1DF5CBC05932),
helpstring("_IAddEvents Interface")
]

// dispinterface _IAddEvents

// interface _IAddEvents : IUnknown
interface _IAddEvents : IUnknown
{
[id(1), helpstring("method ExecutionOver")] HRESULT
ExecutionOver(int Result);
};
[
uuid(C0B7BD5D-B23E-4B9A-9DAE-C32B3CCEF193),
helpstring("Add Class")
]
coclass Add
{
[default] interface IAdd;
//[default, source] dispinterface _IAddEvents; take this line
//out and put the line below in
[default, source] interface _IAddEvents ;

};
};


Add.h:


#ifndef __ADD_H_
#define __ADD_H_

#include "resource.h" // main symbols
#include "ConnectionComCP.h"

/////////////////////////////////////////////////////////////////////////////
// CAdd
class ATL_NO_VTABLE CAdd :
public CComObjectRootEx<ccommultithreadmodel>,
public CComCoClass<cadd, &clsid_add="">,
public IConnectionPointContainerImpl<cadd>,
public IDispatchImpl<iadd, &iid_iadd,="" &libid_connectioncomlib="">,
public CProxy_IAddEvents< CAdd >
{
public:
CAdd()
{
}

DECLARE_REGISTRY_RESOURCEID(IDR_ADD)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CAdd)
COM_INTERFACE_ENTRY(IAdd)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(CAdd)
CONNECTION_POINT_ENTRY(IID__IAddEvents)
END_CONNECTION_POINT_MAP()


// IAdd
public:
STDMETHOD(Add)(int a, int b);
};

#endif //__ADD_H_


Add.cpp

#include "stdafx.h"
#include "ConnectionCom.h"
#include "Add.h"

/////////////////////////////////////////////////////////////////////////////
// CAdd


STDMETHODIMP CAdd::Add(int a, int b)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())

// TODO: Add your implementation code here

Sleep(1000);

Fire_ExecutionOver(a+b);

return S_OK;
}



When I call the Add method from the client program, I got the problem.


Please help!


Best Wishes,
HWB
AnswerRe: help on ATL COM first-chance exeption problem Pin
Stephen Hewitt10-Jan-06 14:13
Stephen Hewitt10-Jan-06 14:13 
QuestionActiveX Pin
Rajesh R Subramanian20-Dec-05 19:29
professionalRajesh R Subramanian20-Dec-05 19:29 
AnswerRe: ActiveX Pin
Aamir Butt22-Dec-05 23:47
Aamir Butt22-Dec-05 23:47 
GeneralRe: ActiveX Pin
vishalmore28-Dec-05 20:03
vishalmore28-Dec-05 20:03 
GeneralRe: ActiveX Pin
lemur211-Jan-06 9:55
lemur211-Jan-06 9:55 
QuestionCreating a COM Pin
vidyarani_14120-Dec-05 10:26
vidyarani_14120-Dec-05 10:26 
AnswerRe: Creating a COM Pin
MarcelDijk20-Dec-05 12:44
MarcelDijk20-Dec-05 12:44 
GeneralRe: Creating a COM Pin
vidyarani_14121-Dec-05 5:03
vidyarani_14121-Dec-05 5:03 
AnswerRe: Creating a COM Pin
MarcelDijk21-Dec-05 11:45
MarcelDijk21-Dec-05 11:45 
GeneralRe: Creating a COM Pin
vidyarani_14122-Dec-05 4:53
vidyarani_14122-Dec-05 4:53 
GeneralRe: Creating a COM Pin
vishalmore28-Dec-05 20:25
vishalmore28-Dec-05 20:25 
AnswerRe: Creating a COM Pin
Brian C Hart30-Dec-05 23:22
professionalBrian C Hart30-Dec-05 23:22 
QuestionImplementing Doc/View/Frame in an ActiveX control Pin
zulat20-Dec-05 2:26
zulat20-Dec-05 2:26 
AnswerRe: Implementing Doc/View/Frame in an ActiveX control Pin
Sheng Jiang 蒋晟3-Jan-06 17:30
Sheng Jiang 蒋晟3-Jan-06 17:30 
Questionproblems with WM_COPYDATA to BSPlayer (C# Pin
bart.burkhardt19-Dec-05 14:30
bart.burkhardt19-Dec-05 14:30 
AnswerRe: problems with WM_COPYDATA to BSPlayer (C# Pin
bart.burkhardt1-Jan-06 11:56
bart.burkhardt1-Jan-06 11:56 
QuestionOut-of-Process DLL Pin
MarcelDijk19-Dec-05 13:43
MarcelDijk19-Dec-05 13:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.