Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

UnsubscribeAllItems. SEHException

More
05 Nov 2019 12:24 #7913 by support
This looks like an internal bug - unfortunately in the unmanaged C++ part which is hard to debug. There is practically no chance to find it without having a reproducible scenario running on our development computer. Do you think you can put together a "minimized" example showing the problem?

Regards

Please Log in or Create an account to join the conversation.

More
04 Nov 2019 15:59 #7910 by Andriy
Hello,

This problem is reproduced when I subscribe to opc items. There are a lot of items being subscribed/unsubscribed

System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at AfxThrowInvalidArgException()
at CEDATopic.ModifyManualUpdateRate(CEDATopic* , UInt32 ManualUpdateRate)
at CEDAAbstractEngine.LockTopic(CEDAAbstractEngine* , CEDAClient* pClient, COCKFindTopicData* FindTopicData, Boolean Automatic, UInt32 UpdateRate, Single PercentDeadband, CEDATopic** pTopic)
at CEDAAbstractEngine.AttachClientAndTopic(CEDAAbstractEngine* , CFindClientData* FindClientData, Boolean ManualBreaks, COCKFindTopicData* FindTopicData, Boolean AutomaticLink, UInt32 UpdateRate, Single PercentDeadband, CEDAClient** pClient, CEDATopic** pTopic)
at CEDAAbstractItem.InternalAttach(CEDAAbstractItem* )
at CEDAAbstractItem.InternalAttachAndConnect(CEDAAbstractItem* )
at OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient.SubscribeItem(EasyDAItemSubscriptionArguments arguments)
at OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient.InternalSubscribeMultipleItems(EasyDAItemSubscriptionArguments[] argumentsArray)
at OpcLabs.EasyOpc.DataAccess.Internal.ForwardingEasyDAClient.SubscribeMultipleItems(EasyDAItemSubscriptionArguments[] itemSubscriptionArgumentsArray)
at OpcLabs.EasyOpc.DataAccess.Internal.ForwardingEasyDAClient.SubscribeMultipleItems(EasyDAItemSubscriptionArguments[] itemSubscriptionArgumentsArray)
at OpcLabs.EasyOpc.DataAccess.Internal.ForwardingEasyDAClient.SubscribeMultipleItems(EasyDAItemSubscriptionArguments[] itemSubscriptionArgumentsArray)
at OpcLabs.EasyOpc.DataAccess.Internal.PSBoxingEasyDAClient.SubscribeMultipleItems(EasyDAItemSubscriptionArguments[] itemSubscriptionArgumentsArray)
at OpcLabs.EasyOpc.DataAccess.Internal.EasyDAClientCompositor.<>c.<SubscribeMultipleItems>b__19_1(IEasyDAClient client, IEnumerable`1 enumerable)
at OpcLabs.BaseLib.Threading.Extensions.IParallelismExtension.<>c__DisplayClass4_1`3.<GroupSelect>b__1()
at OpcLabs.BaseLib.Threading.Extensions.IParallelismExtension.GroupSelect[TSource,TKey,TResult](IParallelism parallelism, IEnumerable`1 source, Func`2 keySelector, Func`3 groupResultSelector, IEqualityComparer`1 comparer)
at OpcLabs.BaseLib.Threading.Extensions.IParallelismExtension.GroupSelect[TSource,TKey,TResult](IParallelism parallelism, IEnumerable`1 source, Func`2 keySelector, Func`3 groupResultSelector)
at OpcLabs.EasyOpc.DataAccess.Internal.EasyDAClientCompositor.SubscribeMultipleItems(EasyDAItemSubscriptionArguments[] itemSubscriptionArgumentsArray)
at OpcLabs.EasyOpc.DataAccess.Internal.CompositeEasyDAClient.SubscribeMultipleItems(EasyDAItemSubscriptionArguments[] itemSubscriptionArgumentsArray)
at OpcLabs.EasyOpc.DataAccess.Internal.ForwardingEasyDAClient.SubscribeMultipleItems(EasyDAItemSubscriptionArguments[] itemSubscriptionArgumentsArray)
at OpcLabs.EasyOpc.DataAccess.Internal.EasyDAClientCompositor.<>c.<SubscribeMultipleItems>b__19_1(IEasyDAClient client, IEnumerable`1 enumerable)
at OpcLabs.BaseLib.Threading.Extensions.IParallelismExtension.<>c__DisplayClass4_1`3.<GroupSelect>b__1()
at OpcLabs.BaseLib.Threading.Extensions.IParallelismExtension.GroupSelect[TSource,TKey,TResult](IParallelism parallelism, IEnumerable`1 source, Func`2 keySelector, Func`3 groupResultSelector, IEqualityComparer`1 comparer)
at OpcLabs.BaseLib.Threading.Extensions.IParallelismExtension.GroupSelect[TSource,TKey,TResult](IParallelism parallelism, IEnumerable`1 source, Func`2 keySelector, Func`3 groupResultSelector)
at OpcLabs.EasyOpc.DataAccess.Internal.EasyDAClientCompositor.SubscribeMultipleItems(EasyDAItemSubscriptionArguments[] itemSubscriptionArgumentsArray)
at OpcLabs.EasyOpc.DataAccess.Internal.CompositeEasyDAClient.SubscribeMultipleItems(EasyDAItemSubscriptionArguments[] itemSubscriptionArgumentsArray)
at OpcLabs.EasyOpc.DataAccess.Internal.ForwardingEasyDAClient.SubscribeMultipleItems(EasyDAItemSubscriptionArguments[] itemSubscriptionArgumentsArray)
at OpcLabs.EasyOpc.DataAccess.Internal.ForwardingEasyDAClient.SubscribeMultipleItems(EasyDAItemSubscriptionArguments[] itemSubscriptionArgumentsArray)
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.SubscribeMultipleItems(EasyDAItemSubscriptionArguments[] itemSubscriptionArgumentsArray)

Please Log in or Create an account to join the conversation.

More
23 Oct 2019 13:17 #7857 by support
Thank you.
How many items are being unsubscribed? A lot?

Can you figure out (e.g. by running outside of the service host) whether the UnsubscribeAllItems call would actually complete - let's say in > 20 seconds, or even couple of minutes - or whether it is truly blocked "forever"?

Here is the reason I am asking:

If the UnsubscribeAllItems simply takes a long time, longer that the time the service host gives it before it forces a process shutdown, but it eventually completes, the solution will be to prolong the time before the service host forces the shutdown. Due to the fact the low-level parts that do OPC COM are written (mixed-mode C++/CLI that uses unmanaged memory), there is simply no way to gracefully stop it "in the middle": it must finalize all its work (which may involve waiting on OPC calls to the server to complete) to shut down properly.

Regards

Please Log in or Create an account to join the conversation.

More
22 Oct 2019 06:40 #7848 by Andriy
Hello,

Yes, everything is correct. When service is stopping I do finalization that hangs in UnsubscribeAllItems. After 15-20 sec the service is forced to stop and than SEHException is occurred

Regards

Please Log in or Create an account to join the conversation.

More
19 Oct 2019 12:59 #7845 by support
Hello,

this is not quite clear to me. Are you saying that the code hangs in UnsubscribeAllItems (for at least 15 seconds, possibly longer)? And that after that time, the SEHException occurs?

Is our code that calls UnsubscribeAllItems tied to the handler for "service stop"?

Regards

Please Log in or Create an account to join the conversation.

More
15 Oct 2019 12:02 #7829 by Andriy
Hello,

I have added additional logging and found that UnsubscribeAllItems() method is called but does not complete. It lasts more than 15 sec.
The cleanup order is:
  1. daClient.UnsubscribeAllItems
  2. daClient.ItemChanged -= OnItemChanged
  3. daClient.Dispose
Regards

Please Log in or Create an account to join the conversation.

More
12 Oct 2019 12:51 #7823 by support
Hello.

Can you please verify (by debugging or logging, not just by looking at the code) that your finalization actually is called and also completes (the UnsubscribeAllItems and Dispose methods return)? This exception seem to happen on call stack that is not yours, but has to do with the final app teardown. So, I'd like to deternmine whether somehow this app teardown happens before or in parallel with your code, or whether your code runs fine and *then* it crashes.

Thank you

Please Log in or Create an account to join the conversation.

More
11 Oct 2019 14:28 #7822 by Andriy
Hello,

It happens when I close my Windows Service application. This is an ordinary app shutdown.
When application is closing I cleanup opened OPC connections: call UnsubscribeAllItems, Dispose
OPC communication mode: subscription

Regards

Please Log in or Create an account to join the conversation.

More
11 Oct 2019 14:14 #7821 by support
Please describe the situation this is happening in.
What kind of project is this? (desktop, web app, etc.)
Is that an orderly application shutdown?
Have you called the UnsubscribeAllItems from your code yourself? (probably not, looking at the call stack).

Thank you

Please Log in or Create an account to join the conversation.

More
11 Oct 2019 13:36 #7820 by Andriy
Hello,

UnsubscribeAllItems method call cause SEHException
Library version: 5.54.1133.1

System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at AfxThrowInvalidArgException()
at OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient.InternalUnsubscribeAllItems()
at OpcLabs.EasyOpcRaw.DataAccess.CDAInnerItem.UnsubscribeAllFromParent(CDAInnerItem* )
at CEDAAbstractEngine.Abort(CEDAAbstractEngine* )
at CEasyAbstractModule.ModuleDestroy(CEasyAbstractModule* )
at OpcLabs.EasyOpcRaw.CInnerModule.ModuleTerminate(CInnerModule* )
at ProcessExitHandler(Object sender, EventArgs e)

System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at AfxThrowInvalidArgException()
at OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient.InternalUnsubscribeAllItems()
at OpcLabs.EasyOpcRaw.DataAccess.CDAInnerItem.UnsubscribeAllFromParent(CDAInnerItem* )
at CEDAAbstractEngine.Abort(CEDAAbstractEngine* )
at CEasyAbstractModule.ModuleDestroy(CEasyAbstractModule* )
at OpcLabs.EasyOpcRaw.CInnerModule.ModuleTerminate(CInnerModule* )
at OpcLabs.EasyOpcRaw.CInnerModule.{dtor}(CInnerModule* )
at _exit_callback()
at <CrtImplementationDetails>.LanguageSupport._UninitializeDefaultDomain(Void* cookie)
at <CrtImplementationDetails>.LanguageSupport.UninitializeDefaultDomain()
at <CrtImplementationDetails>.LanguageSupport.DomainUnload(Object A_0, EventArgs A_1)
at <CrtImplementationDetails>.ModuleUninitializer.SingletonDomainUnload(Object source, EventArgs arguments)

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.064 seconds