|
I have done a GIS implementation in VC++ with Ms-access as back end iwant to convert this into Activex control & place it on the web .Can Anybody helpme out?
A.Satish Kumar
|
|
|
|
|
Hi,
I've created a DCOM Server through the ATL COM Appwizard, I've added a custom (IUnknown) interface and added some methods as below;
[helpstring("method GetComputerName")] HRESULT GetComputerName([out] BSTR *pName);
[helpstring("method GetComputerTime")] HRESULT GetComputerTime([out] long *lTime);
I was able to compile and call these methods thru the client and successfully get the values even from a remote machine.
Now I added a CLIENTINFO Structure in a header file and included the file in the idl using the #import directive,
#import "ClientInfo.h"
I added another method with a pointer to the ClientInfo structure as the parameter as follows
[helpstring("method GetComputerName")] HRESULT GetComputerName([out] LPCLIENTINFO pClInfo);
I was able to compile the code, but when i call this function from the client code, i get an exception and it crashes.
I want to know if we can pass User-Defined Data structures as parameters in a DCOM server? Why is this giving a problem even though i have derived the interface thru IUnknown? Shud we use VARIANTs here, but why shud we since i havent specified an IDispatct \ Automation interface?
The same thing works fine if i create an IN_PROC DLL.
Please tell me how we can achieve this in DCOM, also pls direct me to any examples or tutorials or articles on this.
Thanks,
Anand
|
|
|
|
|
|
Thanks John. Cant this be done if we do custom marshaling. And I have seen an RPC server which takes Struture Pointers as above as parameters in the IDL file.
Thanks
Anand
|
|
|
|
|
Anand Vinod wrote:
Cant this be done if we do custom marshaling.
I believe it can if you do custom marshaling.
John
|
|
|
|
|
Your [out] parameter is incorrect. A pointer-to-a-pointer must be passed in (similar to QueryInterface) :-
HRESULT GetComputerName([out] LPCLIENTINFO *pClInfo);
OR
HRESULT GetComputerName([out] CLIENTINFO **pClInfo);
Implementation :-
HRESULT GetComputerName(CLIENTINFO **pClInfo)
{
*pClInfo = new CLIENTINFO;
(*pClInfo)->m_bstrComputerName = SysAllocString(L"");
return S_OK;
}
The single level pointer that you were passing is only valid within a single process address space.
|
|
|
|
|
Your [out] parameter is incorrect. A pointer-to-a-pointer must be passed in (similar to QueryInterface) :-
HRESULT GetComputerName([out] LPCLIENTINFO *pClInfo);
OR
HRESULT GetComputerName([out] CLIENTINFO **pClInfo);
Implementation :-
HRESULT GetComputerName(CLIENTINFO **pClInfo)
{
*pClInfo = new CLIENTINFO;
(*pClInfo)->m_bstrComputerName = SysAllocString(L"");
return S_OK;
}
The single level pointer that you were passing is only valid within a single process address space.
Jason Lee Duncalf
|
|
|
|
|
Hello,
i am creating an EXE com server through ATLCOMAppWizard. i inserted a NEWAtlObject through insert->newatlobject,i selected simple object then i prefered custom interfaces in attributes and checked the option of support Error information & connection points. i added more interfaces to the object by adding code to .IDL file &compiled it & made necessary changes to cpp file .
finally when build the project i got everything successful & the message of successfully registered component.also seen in the registry about coclass guid present.
i am facing problem to create a client to that EXE-server, i cann't create object via CoCreateInstance though i included MIDL-generated .h &_i.c files in the client code.
please help me in creating client to the above EXE-server.If possible please send a example of EXE-client code.
satish silla
Larsen & Tubro Ltd,
Mumbai.
|
|
|
|
|
Since you are creating a server, you need to create a proxy-stub dll and register it, and specify CLSCTX_SERVER in your CoCreateInstance call
This article shud help you;
http://www.codeproject.com/com/HelloTutorial1.asp
Anand
|
|
|
|
|
Hey guys,
Im trying to write a simple client app
(MFC dialog wizard based app) and I have included the ".tlb" of my component0 to the include folder and added the "#include mycomponent.tlb"
anyidea what this means? how to resolve it.....
thanks
When I tried building at this stage I'm getting the following error message
--------------------Configuration: nativecomclient - Win32 Debug--------------------
Compiling...
StdAfx.cpp
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0x2'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0x1'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0x1'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0x3'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0x81'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0xff'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0xff'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0xff'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0xff'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0x80'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0xff'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0xff'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0xff'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0xff'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0x1'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2146: syntax error : missing ';' before identifier 'A'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2501: 'MSFT' : missing storage-class or type specifiers
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
nativecomclient.exe - 18 error(s), 0 warning(s)
|
|
|
|
|
did you mean to
#import "mycomponent.tlb"
instead of
#include "mycomponent.tlb"
?
|
|
|
|
|
YES !!
I can;t beleive I didnt catch that !!!
I almost gave up on my code !
Thank you so much !
|
|
|
|
|
hello,
i have an local server application exposing some objects with dispinterface events.
and i have a simple .vbs file which creates an object instance, and connects the event interface and releases everything.
Set App = CreateObject( "Server.App" )
WScript.connectObject App, "app_"
WScript.DisconnectObject App
set App = Nothing
wscript.quit
then the wscript crashes with an access violation. if i remove the connectobject line, the wscript terminates without error. seems like the wscript crashes inside the quit method, an messagebox right in front on the quit is displayed correctly.
if i connect the event interface from a c++ client, with atladvise, atlunadvise, everything works, i get no error there.
what could be the problem there? where can i search why the wscript crashes? if have no source for the wscript.
the advise and unadvise marshalls the interface into a stream to make it accessable from any thread.
... error checking
LPSTREAM pStream = 0;
hRes = CreateStreamOnHGlobal( 0, TRUE, &pStream );
if ( SUCCEEDED( hRes ) )
{
hRes = CoMarshalInterface( pStream, iid, p, MSHCTX_LOCAL | MSHCTX_INPROC | MSHCTX_NOSHAREDMEM, 0, MSHLFLAGS_TABLESTRONG );
}
... store stream and return cookie.
maybe there is the problem, i also tried with MSHCTX_INPROC only, but the same error occurred.
thanks in advance
enrico
|
|
|
|
|
Can you check the error within your vbs? I have had to debug vbscript before and what I had to do was add the line "on error resume next" and then in your case add a error check right after the call to connectobject. I typically check if err.number <> 0 then msgbox err.number & " " & err.description. That depends on the security context your script is running under. For debugging, I usually isolate the suspect script into a solitarty script file that I can execute from my desktop, thus inheriting my security rights and msgbox fires with the info I want.
|
|
|
|
|
Hi, i am dealing witha code that uses OLE-Automation to communicate between two different applications.I have added some code to client and it bagan throwing exceptions at server while calling InvokeHelper() for one of interface functions..I have no clue why it throws the exception.I WANT TO DEBUG THROUGH THE SERVER TO UNDERSTAND WHERE THE PROBLEM IS.CAN ANYBODY HELP ME REGARDING THIS.
THANKS AND REGARDS.
|
|
|
|
|
|
Hello,
There is a problem with sysallocstring on .Net server ( both RTM/RC2). If it is called from a global objects constructor, it hangs.
Here are the details -
1. Create a simple in-proc COM dll
2. Implement a function say Foo, which does nothing. It just returns S_OK
3. Write a simple C++ class, in its constructor allocate some memory using SysAllocString.
4. Declare a global instance of the class in the .cpp file.
5. Put OutputDebugString in DllMain, in c++ class's constructor and in function Foo as well.
Now your COM dll is ready with a global object variable.
6. On Windows 2003 .Net RTM / RC2, create a COM+ application for this dll with following configuration
***COM+ application properties-
a. Tab Security - Uncheck option Enable access checks for the application.
b. Tab Identity - use 'This User' identity
c. Tab Activation - Server application
d. Tab Advanced - Enable idle shutdown, set it to 1 minute.
***Component properties
a. Transaction type - required
b. Activation - Object pooling is on, set min level as 20. This is the most import settings. The hang goes away if object pooling if set off.
7. Write a simple windows script to call method foo.
8. Write one more script, say container, which invokes the above said script( Using WScript.Shell object ). After that call add a sleep for 2 minutes. This will ensure that the COM+ application comes up and shuts down properly.
9. Put the call to script ( the one which does createinstance and calls to foo) and the sleep in a loop of 100 iterations.
10. Run the main script, system should hang, it might not hang on first call inself.
Note that this does not occure on all RTM / RC2 machines, but once it occurs it will be there consistently. I am 110% sure about it.
I think its something related to COM+ runtime initialization.
The CoCreateInstance internally first calls Loadlibrary of the COM dll. The loadlibrary will first try to create the global variable and then calls to the dllmain. But the hang occus while creating global objects, if global object creation involves calls to SysAllocString. The call to CoCreateInstance never returns.
If any one want, I can send the dll and scripts as well...
Any clue, why this is happening? Is this a bug in .Net server?
thanks,
Sachin.
|
|
|
|
|
Calls to loadDll are serialized, meaning that a call from dllmain to another module can deadlock the application since the other dllmain needs to be called before calls into the module are allowed - causing a deadlock.
SysAllocString should be located in ole.dll or so.
I agree that it is remarkable that this hangs the whole system.
Do you mean that the whole system hangs?
|
|
|
|
|
Thank you, Thank you, and Thank you again...
I was just about to start a message about how CoCreateInstance hangs, for an hour I have debugged my dll, but after reading your reply, I removed the init code from DLL_PROCESS_ATTACH to an exported function, and Voila! no mysterious deadlock...
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
Here's what I do:
I create an instance of a server using CoCreateInstance and the interface. I check that everything went good using the return
value and continue on.
Here is the problem:
Later on, the server is closed (ex. because no more license is available) but I don't know to get notified by that.
The question:
How can I check that the server is still alive ?
Jonathan de Halleux.
|
|
|
|
|
I checked the support for connectionpoint & support for Errorinfo at the time of inserting a new ATLobject into my server.ATL inserted the interface ISupportErrorInfo in to my coclass also it implemented the method InterfaceSupportsErrorInfo . i want to return rich set of errors to my client applications ,so for that what should i do more so that i can return errors.
thanking u
satish
satish silla
Larsen&Tubro Ltd.
Mumbai.
|
|
|
|
|
You need to look at a few things.
ISupportErrorInfo - to tell the caller that you do give rich error info. This only has one function InterfaceSupportsErrorInfo.
ICreateErrorInfo - used to populate your error info inside your object. This contains set fuctions such as SetDescription, SetSource etc.
IErrorInfo - used by the client to get at the error info. This contains get functions such as GetDescription etc
There are also some other API functions - CreateErrorInfo, GetErrorInfo, SetErrorInfo - that you will need to look at.
Have a look in the SDK under Automation, Error Handling Interfaces.
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
The easiest way how to do it is to use the CComCoClass 's method Error() . There are several overloads, e.g. I personally use the one, which takes the string from the resources. Then the usage is simple:
<br />
Error( IDERR_GENERALFAILURE );
return E_FAIL;
that's all - when the ISupportErrorInfo capable client receives the error HRESULT , it can look for the error info interface and will retrieve my string.
|
|
|
|
|
I would like to wrapp a user defined class with a Variant. In other words, I have obj1 of type class1, and I want to send it to a COM server that takes an object of type class1 as parameter.
How Can I do this? Can I have some examples?
Thanks a lot,
|
|
|
|
|
1. serialize you class using XML (search MSDN for XML serialization)
2. Make your class a COM object and pass in dispatch member of the variant.
|
|
|
|