|
Well, 800a004c is CTL_E_PATHNOTFOUND (olectl.h), so you probably need to point FormatMessage at the right DLL...
Steve S
Developer for hire
|
|
|
|
|
I think the common way of using FormatMessage is like this:
<br />
LPWSTR pwszMsg = NULL;<br />
<br />
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL,hr, 0, (LPWSTR)&pwszMsg, 0, NULL);<br />
How can I know which DLL to point and generate correct message?
Thanks.
|
|
|
|
|
You could try the one you're #import-ing. You're quite right about that being the most common way, though.
Steve S
Developer for hire
|
|
|
|
|
I'm having a problem when calling Excel from within C#.
i have a routine which goes something like this:
<br />
m_Workbook.Addsheet(1) ...<br />
.
.
.
later, m_excelApp (my excel application object) is "Quit":
<br />
m_excelApp.Quit();<br />
This code all works fine. However, after the user closes the Excel workbook (either in the code (via a button) or with the close button on Excel), and I call the above code again, I get an error (at the m_Workbook.Addsheet(1) line):
The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED))
I havent got the faintest what this means (the msdn site doesn't seem to be very helpful regarding a solution) so if anyone could lend us a hand with some advice that'd be highly appreciated!!
Many thanks,
Gerry
COM newbie
|
|
|
|
|
The COM object you're using is a proxy since Excel is a separate application. This proxy object communicates to a stub inside Excel using RPC to provide the illusion that you’re directly driving Excel. If Excel “dies” or is closed down the stub (which lives inside Excel) no longer exists, but the proxy (which lives inside your application) still exists: in this situation any attempt to call a method on the proxy returns RPC_E_DISCONNECTED since the target object no longer exists.
Steve
|
|
|
|
|
Wow thanks Steve for a very educating response!
Can I ask what a way of getting around this might be?
Do I need to kill my m_excelApp object completely? (and if so how??)
Many thanks,
Gerry
|
|
|
|
|
When you get the error the application you're controlling no longer exists; how you respond is up to you. You could pop up an error message for example.
Steve
|
|
|
|
|
OK thanks steve but what if I need to access the application again?
Can I simply recreate the m_excelApp object?
Many thanks for your help!
Gerry
|
|
|
|
|
You can recreate another object, but this may launch another Excel instance. If you're driving an Excel which contains data you want a new instance isn't of much use.
Steve
|
|
|
|
|
Hi.
When I coded a queued component using .NET, I set the activation type to Library.
But, the queued component didn't work.
In the case of Server, it did work.
Can anyone tell me the reason kindly?
Thank you.
Mr. SYH
|
|
|
|
|
Hi,
I am a newbie to COM.
(Part - I)
I have created a VS2003-ATL project and a ATL class(MyClass) in it.
I registered the output dll with regsvr32 (Result - succeeded).
(Part - II)
Next in order to use this COM class(MyClass), I created a VS2003-MFC exe project.
Used the "Add References" to add the COM reference. (Result - I can see the component added in References)
Now I need to use the MyClass in the project. How do I do this?
Any help,links will be appreciated.
|
|
|
|
|
Hi people,
I have an ASP.NET application that uses a COM (locally) to do some number crunching. Everything works fine when the COM is installed on the same machine as the web application. In fact, the ASP.NET application uses a web service to access the COM. The web service is also on the same machine.
Now, for performance reasons, we have decided to distribute the COM to several machines on the network so that we can have some distributed computing. I am not the one who is responsible for the COM development. For testing purposes, we have installed the COM on a remote machine and have created a .NET assembly that will interact with it.
First, I tried the concept using a console application. I reference the assembly, instantiate the class and perform the calculations. The COM works fine on the remote machine with no problems.
Now I am trying to make the ASP.NET application do the same thing as the console application but it's not working. I reference the assembly in my web service code but the call fails.
I know that the COM needs to be configured on the remote machine to allow access and execution. I have noticed that the account that should be used to contact the COM should be a domain account. When I run the console application from my machine, the Dllhost process on the remote machine shows well my username as owner.
I have suspected that because the web application runs with the ASPNET account, it wasn't allowed to run the COM on the remote machine. I have tried using impersonation to switch to my account inside the web service code. The impersonation works fine inside the code. When I debug, I can see that the Environment.UserName field goes from ASPNET to my username. However this doesn't solve the problem.
To check if the impersonation was working, I have tried calling my console application from inside the web service application using the Process class. When I go to the taks manager to see the processes list, I see that ASPNET is the owner of the console application. I have tried calling notepad also and I got the same thing.
So my first questions are:
Does impersonation work only inside the code? Why is my process running under ASPNET?
I have also read some things about delegation to allow a COM to be called across a network. I did some research about the matter and there were some things that needed to be set by the admin, to allow the impersonating account be used for delegation and the impersonated account also. We did all that but still it's not working. I'm sure I'm still missing a lot of stuff since I didn't find any article online that would explain the whole process.
My second question is:
Can anyone point to a URL or maybe explain to me how this delegation works? or maybe if someone has a way to launch a COM across the network, some tips, etc...
Thank you all for your efforts.
Talal
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Hi,
I'm a new dotnet developer and i always hear of COM and COM Components. What is it and why is it used? can u pls explain me abt it?
Regards
Vijay.
|
|
|
|
|
COM means Component Object Model and its a (binary) standard, language-independent, for Creating objects that can interact.
See here http://msdn2.microsoft.com/en-us/library/ms680573.aspx[^].
Event the first period of the above page:
COM is a platform-independent, distributed, object-oriented system for creating binary software components that can interact.
gives a lot of info about.
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.
|
|
|
|
|
|
Hi.
Anyone can tell me about COM+ and DCOM.
Are those same or different?
Please let me know it or any reference url.
Thank you.
Developer
|
|
|
|
|
They are not the same. DCOM is COM with the ability to have not just out-of-process objects, but objects that are on different machines.
COM+ provides a range of different features, such as thread pooling, object pooling, role-based security, and JIT object activation. It can also provide transaction support.
I suggest you look in MSDN online to learn more.
Steve S
Developer for hire
|
|
|
|
|
Hi Experts,
I want to create instance of a inteface(IPropertyBag) ,defind in a ProfMan.dll file so that i can use Add() method define in this interface.
And same name interface exist in ocidl.h file.How can i pass a correct GUID
so that i can access method defind in ProfMan.dll.
i try like this
IPropertyBag* Properties;
hr=CoCreateInstance(__uuidof(PropertyBag),NULL,CLSCTX_INPROC_SERVER,
__uuidof(IPropertyBag),(void**) &Properties);
I took help from visual studio ole to see the id of interface and coclass.
Then i write the following code
const GUID CLSID_IPropertBag ={0x47000673,0x7DB2,0x44C9,
{0x8A,0xC1,0x65,0x26,0x61,0x17,0xD2,0x80}};
const GUID CLSID_PropertBag={0xFC583D50,0xA2F5,0x4656,
{0x8B,0x1D,0x36,0x04,0x88,0xB1,0x83,0xD3}};
hr=CoCreateInstance(CLSID_PropertBag,NULL,CLSCTX_INPROC_SERVER,
CLSID_IPropertBag,(void**) &Properties);
But this time i am unable to access the Add method.
How can i resolve the problrm.
Help me.
|
|
|
|
|
As it's stated, your Interface name conflicts with an existing one. This is not a problem, since only interface UUID matters for COM.
Probably you have to tell us more about your problem, i.e. what kind of error are you experiencing?
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.
|
|
|
|
|
What is the difference between the two and which is used over the other? How does COM play into picture. I know this has something to do with dll hell. Would appreciate to know the divide between the two?
|
|
|
|
|
hi friends,
i am developing a web project using vb .net. here i am using an
activex component made in VB 6.0.it is working fine when run in VS.NET
developemnt server. But when i run this on iis it gives an error.
can not create activex component in line:
myobj= CreateObject("NDEMO.NGDEMO")
however i have registered NDEMO.ocx on machine.
Anybody please help me
thanks very Much.
life is all about helping each other
|
|
|
|
|
hi,
does anyone know a tool or a method to generate a stub COM library from a Type library (tlb)?
I want to provide a com dll without implementation to a customer so that he can start developping. The interface is fixed (type library shouldn't change) but my implementation is not finished yet, so I want to avoid that the customer is starting to work with an untested library...
Many thanks in advance...
gr,
Niko Tanghe
<< Nearly all men can stand adversity, but if you want to test a man's character, give him power. >>
|
|
|
|
|
I am new to the COM programming.
I am trying to dynamically allocate memory using CoTaskMemRealloc(). I am doing this multiple times. In the first call the pointer passed to the routine is NULL pointer. In this first call it allocates the memory and returns the pointer to the allocated memory. But the next call to realloc fails. Why?
I would like to get references where I can get more info on memory management in COM/OLE.
Thanks,
Vivek.
|
|
|
|
|
the following code snippet it's working fine on my system:
HRESULT hr =CoInitialize(NULL);
LPVOID lpvFirst = CoTaskMemRealloc(NULL, 1024);
LPVOID lpvSecond=NULL;
if ( lpvFirst )
{
lpvSecond = CoTaskMemRealloc(lpvFirst, 2048);
}
CoUninitialize();
bvivekb4u wrote: I would like to get references where I can get more info on memory management in COM/OLE.
I don't know specific reference for the above argument. you may find useful general info on the books suggested here [^] and here [^].
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.
|
|
|
|
|
Hi all.
I want to implement frame activex control like "microsoft form 2.0 frame" that can contain my radio activex control with VC++/MFC. I have read msdn articles and I think I must implement ISimpleFrameSite interface on frame control.
How to implement ISimpleFrameSite in VC++/MFC Activex Control? Thank in advance.
|
|
|
|