|
Hi,
I think you should through the exception from you COM+ function, & show / manage detail from where you call the function. Like
Try
{
}
Catch(Exception ex)
{through ex;}
Thanks
Md. Marufuzzaman
|
|
|
|
|
Hi
I haven an ATL COM in-proc server which is crashing randomly. I would not say it as a crash, the server just vanishes after running successfully for 9-10 hours. And then restarts immediately on the next call to CreateInstance() by the clients. I am unable to debug as this is not a crash and happening randomly. Though I'm not providing much details as the code base is huge, any thoughts just to start with would be very much appreciated. I observed that FinalRelease() was called before the server vanishes, but for the initial 10 hours many clients have called FinalCOnstruct() and FinalRelease() without any issues.
Thanks in advance
Harish
|
|
|
|
|
Harish Pulimi wrote: the server just vanishes after running successfully for 9-10 hours
I don't understand what you mean by this. How did you reach such conclusion?
As I interpret your complete description it seems like you're describing the expected behaviour.
I'm quite confident that clients don't call FinalConstruct() or FinalRelease() through any interface. Those functions are called internally by the framework. FinalConstruct() is called when the server is created by a client and FinalRelease() is called when the reference count reaches zero and the server consequently should be destroyed.
This means that if you're experiencing a lot of calls to FinalConstruct() and FinalRelease() your server is being created and destroyed multiple times by its client.
If this is not your intention, I suggest you put a breakpoint in FinalRelease() and you should be able to see the origin of the call in the call stack debug window when the breakpoint is hit. It looks like you expected the server to be created once and then stay alive until the application is closed, but this doesn't seem to be the case given your error description.
Perhaps I have misunderstood what you mean by "vanish" and if that's the case please elaborate on the subject a bit. It could mean that CreateInstance() fails after 9-10 hours, but I think you would have written that as a description of the error if this was the case.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi Roger
Thanks a lot for your reply and apologies for not providing more details.
The architecture is like I have an exe which keeps track of all the servers that will be created by the clients through CreateInstance() calls. This exe needs to run all the time and if not already started, it will start through the next CreateInstance() call made by a client. The problem is that the exe runs fine for around 10 hours and after that it suddenly vanishes i.e. the process just stops, there is no crash reported and the exe immediately starts with the next CreateInstance() call but loses all the previous data. This happens only on some PCs, so I tried putting my debug build on that PC, but still there is no exception, no crash reported, so I thought this could be a heap corruption.
To reproduce this, I have created a test harness where around 100 clients continously bombard the exe with CreateInstance() calls and I could get an exception as follows, not sure whether this is the same crash but it seems like similar to the actual problem. Any idea how to debug the exceptions in OLE32.dll?
First-chance exception in AniteLicenser.exe (OLE32.DLL): 0xC0000005: Access Violation.
OLE32! 77600f3b()
OLE32! 77600ee9()
OLE32! 77600ba0()
OLE32! 7752ad31()
OLE32! 7752ac56()
OLE32! 776007f5()
OLE32! 77602df3()
OLE32! 77600715()
RPCRT4! 77e794bd()
RPCRT4! 77e79422()
RPCRT4! 77e7934e()
RPCRT4! 77e8a384()
RPCRT4! 77e8a3c5()
RPCRT4! 77e7bcc1()
RPCRT4! 77e7bc05()
RPCRT4! 77e76caf()
RPCRT4! 77e76ad1()
RPCRT4! 77e76c97()
KERNEL32! 7c80b713()
One time I could get the following call stack, seems something is going wrong in the Release() call, but the same exe runs fine for around 10 hours (100s of instances were created and released successfully in the meantime) and on a different PC, this exe ran fine for around 3 days:
ATL::_QIThunk::Release(ATL::_QIThunk * const 0x0171d440) line 2734 + 11 bytes
OLE32! 7750d339()
OLE32! 7750d09a()
OLE32! 7752deb3()
OLE32! 7752dcc8()
OLE32! 7752db6a()
RPCRT4! 77e799f4()
RPCRT4! 77ef421a()
RPCRT4! 77ef4bf3()
OLE32! 77600c15()
OLE32! 77600bbf()
OLE32! 7752ad31()
OLE32! 7752ac56()
OLE32! 776007f5()
OLE32! 77602df3()
OLE32! 77600715()
RPCRT4! 77e794bd()
RPCRT4! 77e79422()
RPCRT4! 77e7934e()
RPCRT4! 77e8a384()
RPCRT4! 77e8a3c5()
RPCRT4! 77e7bcc1()
RPCRT4! 77e7bc05()
RPCRT4! 77e76caf()
RPCRT4! 77e76ad1()
RPCRT4! 77e76c97()
KERNEL32! 7c80b713()
|
|
|
|
|
Harish Pulimi wrote: apologies for not providing more details.
No worries. There's no point in posting a lot of details before it's clear what to provide the details for.
I don't really understand your architecture and how this mysterious "exe" keeps track of the running servers. It seems like the "exe" is a COM server itself....
Harish Pulimi wrote: I have an exe which keeps track of all the servers
How is this accomplished if CreateInstance() isn't called from this "exe" in order to create the other servers?
Harish Pulimi wrote: This exe needs to run all the time and if not already started, it will start through the next CreateInstance() call made by a client.
How is the "exe" started?
Is it an out-of-process COM server and "started" with CreateInstance() ?
Perhaps you should consider to have it running as a service.
If the "exe" is an out-of-process COM server that doesn't run as a service, it is quite expected that it will terminate if its reference count reaches zero unless you've provided functionality to prevent it.
The call stack snippets you've provided implies that the call to the server is made in an RPC-thread which means that you're using a multithreaded solution.
In such case it's fairly reasonable to suspect thread synchronization issues, but first we have to agree on how the apartments are set up. So I have a couple of questions for you...
- Are you certain that every thread that uses any kind of COM related stuff contains a call to
::CoInitialize() or one if its equivalents? - Are you certain that every thread that instantiates a COM server has a message pump that will not be blocked?
- What threading model have you registered below the server entry in the registry?
In other words; what value is assigned to the registry value "ThreadingModel" in the registry entry HKCR\CLSID\{<your server CLSID>}\InprocServer32 ? - How is the apartment initialized from which you create the server?
I suspect it is initialized as a multithreaded apartment. - Are you using proper marshalling? How?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Finally found the bug. In the client code COM library was not being initialized properly.
Because of this, it is unable to tear down the connection to the server. Now everything works as expected.
|
|
|
|
|
Can you please share this solution with more details? I am seeing the similar kind of issue, and unable to drill down to root cause and solution.
--Ashish
|
|
|
|
|
How can we determine the sizeof object from the interface pointer?
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|
|
No, not unless the interface in question exposes a method for it.
An interface pointer is just what it says - a pointer.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
You don't. What's more, if you want to you're misunderstanding COM.
Steve
|
|
|
|
|
Stephen Hewitt wrote: What's more, if you want to your misunderstanding COM.
Nice. Can you tell that to the guy in my thread just below?
|
|
|
|
|
Sometimes there is no object behind the interface pointer at all, only the set of functions.
With best wishes,
Vita
|
|
|
|
|
Hello,
i need to convert a system.__comobject to a byte[] in C# .Net
greetings,
Sander
|
|
|
|
|
Sander1234321 wrote: i need to convert a system.__comobject to a byte[] in C# .Net
I suppose if you know the size of the com object in bytes you can marshal the memory into managed memory, however my guess is that is not what you want.
|
|
|
|
|
i tried that with the following code:
int structsize = System.Runtime.InteropServices.Marshal.SizeOf(obj);
but it raises an error namely: "Type 'System.__ComObject' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed."
greetings,
Sander
|
|
|
|
|
Sander1234321 wrote: but it raises an error namely: "Type 'System.__ComObject' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed."
DUH, that's why I said:
led mike wrote: I suppose if you know the size of the com object in bytes
I also said:
led mike wrote: however my guess is that is not what you want.
I have nothing new to add so this post is completely redundant.
|
|
|
|
|
I have written a COM DLL which gives the
out parameter as BSTR**(Typically 2D Char Array).
This COM function will fill the values of BSTR** variable.
I am able to use this function sucessfully in MFC Application.
But I face problem in using it in C#.
The Sample code is as follows:
///////////COM Function////////////////////////////////////////
STDMETHODIMP CSampleTest::GetAllDeviceList2(BSTR** szMaclist)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
for(int i=0;i<10;i++)
{
szMaclist[i] = new BSTR[100];
wchar_t *szTmp = new wchar_t[100];
wsprintf(szTmp,L"Device%d",i+1);
*szMaclist[i]=SysAllocString(szTmp);
}
return S_OK;
}
///////////////////////////////////////////////////////////////
I acessed this in VC++ by,
BSTR **szMaclist = new BSTR*[10];
CoInitialize(NULL);
HRESULT hr = CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,iid,(void**)&pText);
if( SUCCEEDED(hr) )
{
pText->GetAllDeviceList2(szMaclist);
pText->Release();
}
and i am sucessful in acessing this function in MFC Application.
Can anyone tell me how to acess GetAllDeviceList2() function in c#.
|
|
|
|
|
Try using SAFEARRAYs rather than standard C arrays. That way, there should be metadata in the type library or something that can help the process.
This CP article[^] might help
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.TypeInitializationException: The type initializer for 'AMP.mdlCaiDat' threw an exception. ---> System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154.
at AMP.mdlCaiDat..cctor()
--- End of inner exception stack trace ---
at AMP.mdlCaiDat.InsertTimeAll(String idcard, String TimeInOut, String tablename, Byte TongSLC)
at AMP.mdlFnRac.FN_save(Byte p_id)
at AMP.frmRac.btnDownloadData_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
AMP
Assembly Version: 2.0.0.1
Win32 Version: 2.0.0.1
CodeBase: file:///D:/PM%20cham%20cong%20AMP/Chuong%20trinh/AMP.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
KTMDK
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///D:/PM%20cham%20cong%20AMP/Chuong%20trinh/KTMDK.DLL
----------------------------------------
System.Data
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Transactions
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
Interop.Excel
Assembly Version: 1.5.0.0
Win32 Version: 1.5.0.0
CodeBase: file:///D:/PM%20cham%20cong%20AMP/Chuong%20trinh/Interop.Excel.DLL
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
|
|
|
|
|
Error 0x80040154 indicates you haven't registered your COM component. Registration-free COM interop[^] might be want you want.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I was trying to write COM wrapper for a 3rd party .net library (basically wrote few functions based on that library). So, I followed all the steps given in the msdn site, and VB6 IDE was detecting it fine and all the implemented functions were showing up correctly, but there is one problem. Nothing was working and program was crashing at point where those functions were referenced, because it just see the wrapper but doesn’t find the actual library, My question is, what I am doing wrong? Is there any way I can wrap my COM wrapper and library together?
Thank you,
Arya
|
|
|
|
|
Dear all,
I am having an out of memory problem in Matlab with using a proprietary DLL to read data that was recorded using that company's software and equipment.
I have went through the problem with the software engineer at the company and he is quite certain that it is not due to leaking memory because the DLL only creates the memory object once and reuses it.
The DLL (data reader) is loaded using the actxserver command in matlab. The DLL retrieves data based on events, so I registered the event using: registerevent({'DataReady' 'DataReady_function'});
That is, when the user asks for data, the DLL sends it back via the event callback function in Matlab: 'DataReady_function'.
I have inserted "clear VARIABLES" throughout the functions to ensure that I have cleared all variables that were no longer used. When the data came in via the event handler as "varargin", I even loaded everything in (i.e., FULL_DATA = varargin) and taken out the data (i.e., Data = varargin{7}) and then applied "clear" to the whole "varargin" (i.e., clear FULL_DATA).
The problem is that as I loop through the function, reading through the stored data on the hard drive, more and more memory gets held up by Matlab, even though I am not actually storing any data within Matlab (just consistently reading in small bits of data and then clearing it). If I let it keep running, Matlab eventually runs out of memory. If I stop it before it runs out and try to "clear all", Matlab still holds onto the memory and will not release it (I confirmed this by looking at the memory usage under the processes tab in Windows Task Manager).
From what I can gather, Matlab must be trying to protect all the bits of data that comes in via the event callback, but I just don't know how to tell Matlab that the data has been read and it does not need to protect it any longer. If you have encountered this problem or know how to resolve it, please let me know.
I am really stuck and would really appreciate your help. Thank you very much.
Yours sincerely,
Alan
|
|
|
|
|
LaiAlan wrote: I am having an out of memory problem in Matlab
How have you verified this?
Did MatLab crash due to low memory or did it display a message that told you it was running low on memory?
If you base all this on the figures in Task Manager you should really have a look at this article[^].
LaiAlan wrote: If I let it keep running, Matlab eventually runs out of memory.
Have you actually experienced this?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Yes, Matlab crashed due to low memory. The actual error message is:
??? Out of memory. Type HELP MEMORY for your options.
Error in ==> comeventcallback at 3
args = hEvent.get;
Warning: Error occurred while evaluating listener callback.
After it has ran out of memory and stopped "reading and clearing data" (i.e., I did it to make sure it doesn't use more and more memory), "clear" did not change the memory used by Matlab at all:
>> memory
Maximum possible array: 8 MB (8.389e+006 bytes) *
Memory available for all arrays: 69 MB (7.256e+007 bytes) **
Memory used by MATLAB: 2767 MB (2.901e+009 bytes)
Physical Memory (RAM): 3326 MB (3.487e+009 bytes)
|
|
|
|
|
LaiAlan wrote: ??? Out of memory. Type HELP MEMORY for your options.
Error in ==> comeventcallback at 3
args = hEvent.get;
Warning: Error occurred while evaluating listener callback.
This looks interesting. It looks like an error message from MatLab
To me it seems reasonable that such an error won't occur unless the application is trying to allocate memory. The text "Error occurred while evaluating listener callback", makes me suspect that this error occurs before your callback is called.
The above suggests that MatLab is allocating memory internally prior to calling your callback. This could be due to how the callback interface is declared.
What does the callback interface look like? Post the declaration of it.
If you don't allocate any memory in your callback and the third party DLL doesn't allocate memory when calling your callback, then it must be some kind of internal MatLab stuff that is going on and it should be possible to find in the MatLab documentation.
Have you tried writing another client to avoid MatLab related stuff with e.g. MFC?
What happens?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|