Link to home
Start Free TrialLog in
Avatar of ivanadu
ivanadu

asked on

Strong name for unsafe C++ assembly (dll) to be calles by C# application

Hello, I am trying to import (Dll import) into a C# application, a C++ dll, wrapping a third party USB driver API. Everything runs smoothly but sometimes the application consumes even up to 99% of cpu. By running process check up, I have discovered that from time to time (at moments of high cpu load) an invisible exception occurs, at the dll level related to the StrongNameErrorInfo. Next to that exceptions related to unregisterassembly and other similar issues.
Well started searching for Strong, Weak name signing assembly and found nothins related to this situation.
Does anyone have a solution?

Thanks.  
Avatar of abel
abel
Flag of Netherlands image

might it be that the "next to that exceptions..." are a result of the earlier exceptions? I.e., that the unwinding in the dll does not go smoothly and hence the unregisterassembly etc do not work as smoothly either?

it seems likely that the error either occurs in your wrapper, or in the third party usb driver. Maybe you can add structured exc. handling in your wrapper (if not already there) to at least log any exceptions that occur from the driver?
Avatar of ivanadu
ivanadu

ASKER

I'll give it a try. I am back within an hour :)
Avatar of ivanadu

ASKER

ntdll.dll!KiFastSystemCallRet
FTD2XX.dll!FT_IoCtl+0x56
mscorwks.dll+0x1b4c
mscorwks.dll!DllUnregisterServerInternal+0x61ad
mscorwks.dll!StrongNameErrorInfo+0x53ee
mscorwks.dll!StrongNameErrorInfo+0x55a6
mscorwks.dll!StrongNameErrorInfo+0x56ca
MyDll.dll!MyThreadFunction+0x83
KERNEL32.dll!BaseThreadInitThunk+0x12
ntdll.dll!RtlInitializeExceptionChain+0x63
ntdll.dll!RtlInitializeExceptionChain+0x36

ptr is a reference to a function from the c# application passed at init time.
Most of the times this works, and when the communication load is high it fails.

typedef void (__stdcall *pTempMessageHandler)(unsigned long);
 
	unsigned long bytes2Read;
	unsigned long bytes2Send;
	unsigned long eventStatus;
 
	pTempMessageHandler ptr = (pTempMessageHandler)pContext;
	while (applicationRun == true)
	{
		unsigned int uiTemp = WaitForSingleObject(hEvent,INFINITE);
		try
		{
		if (applicationRun == true)
		{	//(handle, *dword, *dword,	*dword);
			FT_STATUS ft_status = FT_GetStatus(ftHandle,&bytes2Read,&bytes2Send,&eventStatus); 
			(ptr)(eventStatus);
		}
		}
		catch (char * str)
		{
			//cout << "Exception raised: " << str << '\n';
		}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ivanadu
ivanadu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
glad you found it. I was just thinking of a way to help you further, but it isn't easy with this type of errors if you're not behind the machine (physically or remotely).
Avatar of ivanadu

ASKER

i know, once you search for such an error, you wonder if that is the right path. simplifying was the only option and minimizing interaction between c# and c++...
still not sure about this manually reset event, but once in correct position before reading how many bytes are in the queue i do not expect problems  

thanks again