|
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.
|
|
|
|
|
Hi,
I build a singelton comobject, to be a 'meetingpoint' for different processes located on remote computers.
I've got a method called:
[id(2), helpstring("method ConnectMachine")] HRESULT ConnectMachine([in] IUnknown* pUnk, [in] BSTR strMachineName);
which connects a client to the meetingpoint and passes an interfacepointer to an interface implemented on the client, for callbacks.
The 'meetingpoint' objects saves the machinename and the interfacepointer
in a list for every connected machine.
If I now use this interfacepointer to call methods on a client this is no problem, and works well.
But i want to go a little further, and want to retrieve an interfacepointer from one client to another over the meetingpoint by a method called:
[id(3), helpstring("method GetMachineInterface")] HRESULT GetMachineInterface([in] BSTR strMachineName, [out] IUnknown** ppvObject);
which should retrieve an interfacepointer by the machinename.
If I try this, a get the errormessge "invalid access to memory location" on the client side.
Does anybody known why?
Thanks for help!
Elch
|
|
|
|
|
Can you give a sample how client handles return values from
"HRESULT GetMachineInterface([in] BSTR strMachineName, [out] IUnknown** ppvObject);" ?
|
|
|
|
|
Of course,
try
{
hr = m_pIMachineConnectionPoint->GetMachineInterface("TESTMACHINE", &pUnk);
if (pUnk)
{
IMachine* pMachine;
hr = pUnk->QueryInterface(__uuidof(IMachine), (void**)&pMachine);
if (SUCCEEDED(hr))
pMachine->StartProductionMode();
}
}
catch (_com_error e)
{
// here I get the error message: "Invalid access of memory location"
....
I think it has something to do with marshalling,or??
Thanks!
elch
|
|
|
|
|
GUESS 1
If you do not mind change
"if(SUCCEEDED(hr))"
to
"if (SUCCEEDED(hr) && 0 != pMachine)"
If I am right Query interface returns null pointer
GUESS 2
Inspect ( and publish here if possible for me to examine) StartProductionMode() code, I suspect there is uninitialized pointer.
|
|
|
|
|
Sorry, I didn't mentioned that if I try to execute the line:
hr = m_pIMachineConnectionPoint->GetMachineInterface("TESTMACHINE", &pUnk);
then an exception occures, and I get the error "Invalid acces to memory location" from e.ErrorMessage().
I think the has something to do with marshalling, because the interfacepointer stored in the list of the meetingpoint object, is marshalled to the machine on which the meetingpoint object is running. And I do not know if COM automatically remarshalls the pointer for the third machine??
-----------------
| |
| meetingpoint |
------------- | IpointerList | -------------
| |----------------------| |--------------------| |
| Machine 1 | ----------------- | Machine 2 |
| | | |
------------- -------------
Machine 1 and 2 are connecting to meetingpoint object and interfacepointers are stored in Ipointerlist.
Client:
m_pIMachineConnectionPoint->ConnectMachine(pUnk, m_MachineName.AllocSysString());
Then machine1 tries to get an interfacepointer from Ipointerlist of machine2, I'm not really sure if COM automatically remarshalls the interfacepointer to point directly to machine 2.
Thanks!
|
|
|
|
|
It should remarshal it (I think ), if not you can easily do it yourself (CoMarshalInterface) . The reason I am not totally convinced is that the error code is nothing like marshaling, it seems you have some un-initialized pointer. If it is ConnectMachine I would put a lot of tracing logic in it to see exactly what breaks.
|
|
|
|
|
The first parameter of GetMachineInterface is a BSTR one. Therefore you need to pass strictly BSTR value, not char* or wchat_t*.
BSTR machname = SysAllocString(L"TESTMACHINE");
hr = m_pIMachineConnectionPoint->GetMachineInterface( machname, &pUnk);
SysFreeString( machname );
or
hr = m_pIMachineConnectionPoint->GetMachineInterface( bstr_t(L"TESTMACHINE"), &pUnk);
or
hr = m_pIMachineConnectionPoint->GetMachineInterface( CComBSTR(L"TESTMACHINE"), &pUnk);
With best wishes,
Vita
|
|
|
|
|
I believe this is your problem. You should also change the following code:
if (pUnk)
to
if (SUCCEEDED(hr))
John
|
|
|
|
|
i want to write a simple addin for VS.NET, which comments(like //##MYNAME**NR2003##//) the selceted lines of code.
this is all finde and easy, but i have now a hughe problem:
if "selction margin" is switched on (under tools/ options/texteditor), then the addin does not work properly, when selecting code, that contents of outlined code.
when i make things like:
pTextSelection->get_CurrentLine(&lCurrLine);
pTextSelection->get_TopLine(&lTop);
pTextSelection->get_BottomLine(&lBottom);
i get only the linenumbers of the code currently visible on the screen. but i also want the numbers of the lines who are outlined!
how can i do this???? i didnt found any function!
the only function i found is the one to outline code
(->OutlineSection) but i would like to do the contrary!!!
please help me!
thanx, andreas
|
|
|
|
|
Hi all,
I have a stupid problem but I do not know if it can solved some way. While trying to compile a ATL/COM component, I want the MIDL compiler include some other .idl files stored in a path like C:\Program Files\DanLoad 6000\Include.
So I put the project settings for MIDL compiler with the /I option (/I "C:\Program Files\Danload 6000\Include").
When I try to build the project, I get the follwoing error. It look as if the MIDL compiler does not understand blanks in the path for include files.
Anyone can help?
Thank you in advance.
--------------------Configuration: DldDanload6000 - Win32 Debug--------------------
Creating Type Library...
Microsoft (R) MIDL Compiler Version 5.01.0164
Copyright (c) Microsoft Corp 1991-1997. All rights reserved.
Processing C:\temp\DldDanload6000\DldDanload6000.idl
Danload
fatal error C1083: Cannot open source file: 'Files\Danload': No such file or directory
6000
fatal error C1083: Cannot open source file: '6000': No such file or directory
Include
fatal error C1083: Cannot open source file: '6000\Include': No such file or directory
DldDanload6000.idl
midl : command line error MIDL1003 : error returned by the C preprocessor (2)
Error executing midl.exe.
DldDanload6000.dll - 4 error(s), 0 warning(s)
_________________________________________________________________________
|
|
|
|
|
Why do you want to include the .idl file? Do you need the interface declarations of other some other coclasses? One solution is to include the .c and .h files.
Kuphryn
|
|
|
|
|
Difficult to say - but just a wild guess - if you put the /I "C:\Program Files\Danload 6000\Include" option, it will receive the path as:
C:\Program Files\Danload 6000\Include
from the command line. And when it is just passed to another procedure or where, it might be misunderstood.
I would try:
/I """C:\Program Files\Danload 6000\Include"""
or something similar, just to achieve the effect, that the MIDL will receive
"C:\Program Files\Danload 6000\Include"
instead of mentioned
C:\Program Files\Danload 6000\Include
Maybe this helps...
|
|
|
|
|
I'm interested to know if this one works, because I'm having the same problem passing a response file name to the csc.exe compiler.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|