|
You could also take a look at aggregation and containment if you are trying to perform it from the server side. It is not necessarily that COM doesn't support good programming practice, the whole reason for the development of COM was to insulate the client from the details of implementation; thus implementation inheritance is out of the question since it requires too much detailed information over how the "insides" work. COM does support interface inheritance, which is developed through aggregation and containment. These tools allow you to specialize COM interfaces.
|
|
|
|
|
I wrote a piece of code as
hr = CoCreateInstance (&CLSID_DataAccessClient, NULL, CLSCTX_INPROC_SERVER, &IID_IDataAccessClient, &pCOM);
where pCom is of type IDataAccessClient.
The program throws a Fatal error as:
Fatal execution engine error.
Please help me out by giving some suggestions.
Biswa
Email: biswaranjan.rath@amdocs.com
Phone No: 09373311346
|
|
|
|
|
Try this instead:
hr = ::CoCreateInstance(CLSID_DataAccessClient,
NULL,
CLSCTX_INPROC_SERVER,
IID_IDataAccessClient,
(void**)&pCOM);
if(FAILED(hr))
{...}
Notice the absence of the & operator.
I Dream of Absolute Zero
|
|
|
|
|
I tried those options, but i'm using a reference so '&' is needed. again i tried this with (void**). still i got the error. Even this call doesn't return a status.
|
|
|
|
|
Ok. I'm still not quite sure why you need to pass the address of the GUIDs like you did though.
The only other possibility that I can think of is that the COM library was not initialised. Have you called ::CoInitialize(NULL) at the start of your program?
I Dream of Absolute Zero
|
|
|
|
|
I have initialized thye COM library by:
hr = CoInitialize(NULL);
after that i checked the status of hr, which is returning success.
then the program fails in CoCreateInstance()
|
|
|
|
|
biswaranjan_rath wrote:
hr = CoCreateInstance (&CLSID_DataAccessClient, NULL, CLSCTX_INPROC_SERVER, &IID_IDataAccessClient, &pCOM);
What is Return Value of hr here
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hello everyone. I know this is a newbie question but I have to ask. I am pretty comfortable with windows programming in C and C++ as a whole however I am still sketchy over COM development. Specifically I would like to tie in my office solutions to my Visual studio solutions. I understand that interacting with Office requires COm deployment and I was hoping someone might point me in the right direction for finding a good reference. When I first started Windows programming I was told to get Petzold's book. I think it was one of the best investments I ever made. I was wondering and hoping frankly, that there was an equivalent to that with respect to COM programming.
|
|
|
|
|
Hi,
You can check my COM BLOG[^]. I have listed some good book names and useful URL's (Notes: These are my personal favourites)
Have a great day ahead!
Regards,
Sohail Kadiwala
(My Blog - http://blogs.wdevs.com/sohail/[^])
modified 21-Apr-21 21:01pm.
|
|
|
|
|
I have just ordered a copy of Inside COM and I was looking into Inside OLE. I was wondering if anyone has read these books or have any other suggestions.
|
|
|
|
|
Hi Folks,
I am writing an Attributed COM component in Visual C++ 7.1. In standard cases, the name of the coclass is the same as the CLASS name. I want to know if it is possible to change the coclass name ?
For instance, in the following code of mine, IDL will be generated with the coclass named as "CMyData". But, I want to have the coclass name as "MyData" without changing the actual class name.
[CODE]
[
object,
uuid("19088A64-4E82-4FD7-A8A5-A9FEE2577FE8"),
dual, helpstring("IMyData Interface"),
pointer_default(unique)
]
__interface IMyData : IDispatch
{
[id(1), helpstring("method MyMethod")] HRESULT MyMethod();
}
[
coclass,
threading("apartment"),
support_error_info("IMyData"),
vi_progid("MyComponent.MyData"),
progid("MyComponent.MyData.1"),
version(1.0),
uuid("4AF80BC4-6A51-4E83-A3A0-9184230CD2AD"),
helpstring("MyData Class")
]
class ATL_NO_VTABLE CMyData : public IMyData
{
public:
CMyData();
virtual CMyData();
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
STDMETHOD(MyMethod)(void);
}
[/CODE]
Any help would be appreciated.
Regards,
Arun.
|
|
|
|
|
I am trying to develop a COM addin for Outlook 2003 using C#. I have read Hannes Pavelka's article on creating toolbars and buttons in Outlook. But, every button that I added only shows up in the main Outlook window. I'm not able to get anything new to show up in the message composition window. Does anyone know how to do this?
|
|
|
|
|
The GnucDNA is a component for building P2P applications. It is written in C++. Examples of how to call it from VB.NET and C#.NET can be seen at http://www.gnucleus.com/GnucDNA/docs/examples.html. Works fine for most methods in GnucDNA, but one crucial call to a method called SetSharedDirs is not shown in the examples, and for a good reason: It does not work, it requires the argument to be passed as a string array pointer.
Looks like Microsoft is trying to explain something about how to do it by marshalling at http://samples.gotdotnet.com/quickstart/howto/doc/Interop/StringMarshal.aspx. Also, seem like using unmanaged code in C# by declaring keyword “unsafe” and statement “fixed” may hold a key, but how?
The C++ - method in the .COM can be seen at http://cvs.sourceforge.net/viewcvs.py/gnucleus/GnucDNAR2/ComShare.cpp?sortby=date&view=markup, and looks like so:
void CComShare::SetSharedDirs(VARIANT* pDirPaths)
Anybody able to come up with a call from VB.NET or C#.NET that does not produce a type mismatch – error?
|
|
|
|
|
I hope someone might be able to answer this puzzle that I've found while testing a component of mine.
I am using Excel's VBA environment to quickly test a few of the methods in my component. Now if I create my component, specifying the type explicitly and run the method, everything works OK.
eg:
<code>
Dim Obj as MyItem
Dim strTitle As String
Set Obj = New MyItem
strTitle = "Some Description"
call Obj.SetTitle(2057, strTitle)
Set Obj = Nothing
</code>
Now here's the weird bit. If I create my item from an Object variable, it fails on my call to the same method. So if I change my code to:
<code>
dim Obj as Object
Dim strTitle As String
Set Obj = New MyItem
strTitle = "Some Description"
<font color=red>call Obj.SetTitle(2057, strTitle)</font><font color=green>' This FAILS with 'Type Mismatch' error </font>
Set Obj = Nothing
</code>
I can get access to the other properties of the item, but for some reason, it will not call this function.
Am I missing something?
There must be a simple explanation for this.
I Dream of Absolute Zero
|
|
|
|
|
UPDATE
Its gets stranger.
If I replace the String variable by a litteral text, it works!!
call Obj.SetTitle(2057, "Hello") 'Works!!
WTF! Are string types treated differently when called via an Object type?
Why is this happening ? Someone enlighten me.
I Dream of Absolute Zero
|
|
|
|
|
Are string types treated differently when called via an Object type?
Of course. Strings can be passed by VARIANT with VT_BSTR (your second case) or VT_BSTR|VT_BYREF (your first case).
Probably, the Invoke-helper for your class cannot process this vt-value.
Set the breakpoint inside Invoke(...) of your class and test it.
PS
Your can also get the valid result with extra parentheses around String.
call Obj.SetTitle(2057, (strTitle))
With best wishes,
Vita
|
|
|
|
|
Cheers.
I suspect it does have to do with parameters passed via Variant, ByValue, By reference, or a combination thereof I don't want to spend too much brain time in the VBA environment, so as long as it works
I solved the problem by explicitly casting the type value. So this works:
<br />
call Obj.SetTitle(CInt(2057), CStr(strTitle))
I Dream of Absolute Zero
|
|
|
|
|
Hi all,
I create a COM in VC++. It has a funtion that returns a SAFEARRAY (IDispatch*)
. if I use this Com in c++, it works fine, but if I call this function in matlab, it causes problem.
Does any one have experience on it?
Thank you for any help.
Tran Phuong Nga
|
|
|
|
|
Try wrapping it into a VARIANT instead.
I.e.
HRESULT MyMethod([out,retval] VARIANT * pVar);
And the variant is initialized like this (roughly):
VARIANT l_var;<br />
VariantInit(&l_var);<br />
l_var.vt = VT_DISPATCH | VT_ARRAY;<br />
l_var.parray = your_safe_array;
|
|
|
|
|
Hi,
thank you for your help.
But the problem comes from the following code:
SafeArrayCreateVector(VT_DISPATCH, 0, length);. If I hide this code, no problem any more.
If the code is SafeArrayCreateVector(VT_INT, 0, length); or SafeArrayCreateVector(VT_BSTR, 0, length);.., no problem.
So eventhough I wrap the return value into VARIANT type, I still have to call SafeArrayCreateVector(VT_DISPATCH, 0, length);, then the problem is still there.
Do you know how to solve it, or is there any other ways to create a vector of IDispatch*?
Thank you.
Nga
|
|
|
|
|
Does anyone know if there is a way how to export emails from the Inbox/Outbox into .msg files programmatically?
I tried using the Outlook Object Model, but it asks the user for permission to access the mailboxes and ideally I would like to avoid that (no, i'm *not* writing a virus... - i just would like to do away with user interaction while the program is running ).
I also tried using MAPI, and i managed to read emails individually into the IMessage interface, but I can't see how I can stream its properties to a file without iterating on the properties one by one (and potentially risking modifying one property indadvertedly and ruining the entire message).
My recent attempt has been with CDO but again, the MessagePtr interface in cdo.dll doesn't seem to support any streaming.
Anyone has a better idea?
|
|
|
|
|
|
Hi,
I have a com DLL that I am utilising in an ASP net application. When I use the COMM DLL in a windows form application an when I call methods on the DLL there is no problem, when I use the the DLL in a asp.net application I get the following error : "System.Runtime.InteropServices.SEHException, Message : External component threw an error". What could be the problem, where do I start looking for the error ?
Vinesh
|
|
|
|
|
Hi all !
I was assigned a task which I don't think is possible to do.
What I was requested to achieve is basically the following:
To cause our existing MFC (Doc/view) application to become a COM EXE server !
Is it possible at all, or am I wasting my time. If it's not possible, what approach shall I take?
I used the information which appeared under the article :
Article ID :175190
Last Review:June 29, 2004
Title : How to add ATL support to an MFC EXE
Link : http://support.microsoft.com/default.aspx?scid=kb;EN-US;175190[^]
Outcome so far : NOT Successful, meaning, the registration is not failing, but the server cannot be found by a client application (class not registered !)
As far as I understand , the article 175190 discusses the option of
embedding an "local In-process COM server" into the application, not a "remote COM EXE server".
I tried everything I know, so far with no results..
Please help,
Rubi
|
|
|
|
|
I can assure you that it is possible, as I have been forced to do the same myself in the past. How I approached the problem was to build test out-of-process MFC EXE applications from scratch using the MSVC wizards, and contrasted that with a similar standalone EXE application without ATL, and researched each extra line added by the wizard. I must admit that the MS article that you have found looks to be good, and if I had had found the same article it would have saved me much time.
One of the problems that I remember was in coding the clients. For a straight automation enabled MFC SDI application, the client calls the IMyApp.Document interface, which you can access via CreateDispatch() and related function. If you were building a COM EXE server without a document interface, the client interface initialized using CoCreateInstance(). This may be the source of your problem.
Feel free to ask more specific question, and I will do my best to remember.
|
|
|
|
|