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.
- Forum
- Discussions
- QuickOPC-Classic in .NET
- General Issues, Building
- System.TypeInitializationException: The type initializer for 'OpcLabs.EasyOpc.DataAccess.EasyDAClient' threw an exception
System.TypeInitializationException: The type initializer for 'OpcLabs.EasyOpc.DataAccess.EasyDAClient' threw an exception
Regards,
Please Log in or Create an account to join the conversation.
I set 45 seconds as timeout value, all the application starts without any errors in startup.
I have license for the version QuickOPC-Classic 5.12.1308.1, Can I use the same license for the latest version 5.23.1225.1 or should I purchase a new one?
Thank you
Please Log in or Create an account to join the conversation.
The change will also be in the next build of version 5.30, but that one is not available yet. It will also depend on your feedback for this update to version 5.23.
Best regards
Please Log in or Create an account to join the conversation.
Let me know when a new build is available. I expect this changes in both versions 5.23 and 5.30, since I may use both .Net versions 3.5 as well as 4.5
Please Log in or Create an account to join the conversation.
Version 3.02 did not have this kind of assembly loading procedure. It was introduced because we need to seamlessly handle 32-bit and 64-bit environments, and we have a low-level assembly that is written in C++/CLR that has to be compiled to either x86 or x64 architecture, but cannot be compiled to MSIL only. But we want the upper layers appear as MSIL only, therefore we cannot reference the low-level assembly directly and have to resort to various tricks. What you are seeing is the architecture-specific assembly file being placed into a shared temporary area - which cannot be done simultaneously by two processes, hence the need for a global lock.
Placing the file alongside the app would not resolve the issue in general case, because there can be multiple apps placed in the same directory, or even the same app may be started multiple times.
We have some plans for improvements in this area, but they cannot be done quickly.
For now I will proceed as indicated earlier. I will let you know here when the updated build is available.
Please Log in or Create an account to join the conversation.
Thank you for dealing this issue.
Configuring the timeout value from the config file is good. But, still there may be a possibility to get the Timeout Exception at some cases. So, please think of it.
I think the global shared file is created in the Temp folder with name like amd64_OpcLabs.EasyOpcClassicRaw_5.23.1211.1.dll. But the OPC Web Client 3.02 does not generate the global file in Temp folder (I do not know that, it may generate the global file some where). Is there any possibility that instead of sharing the global file, can you generate individual file for each application? or can you add a configuration to
1. Share the global file (or)
2. Create an individual file for each application
Please Log in or Create an account to join the conversation.
thank you for more details.
It looks like that the error now properly reflects what is happening. The globally shared file is guarded by a mutex, and we could not get a hold of it for some time. Possible reasons:
- one of the apps is indefinitely stuck somewhere during assembly loading (not sure why this could happen)
- works as designed, but the first app operations are so slow that the other times out
- other kind of bug in our or your code (unlikely)
I currently thing we are dealing with #2. You are starting the apps at the same time, right? (nothing wrong with that). And, it might be relatively slow/old machine? And, when it's during system startup, I can imagine that the system might have decided too many other things at the same time, so even if it's no one of our own apps that is resource demanding, the overall system performance at that particular point in time might be very low.
The timeout we are dealing with is currently hard-coded at 10 seconds. I suggest that we do the following:
- We will make the timeout configurable (in a config file that you place alongside the app's EXE)
- And, we will increase the default somewhat.
What do you think?
Please Log in or Create an account to join the conversation.
I still have issue, Please see below.
1. I tested the OPCTest1 and OPCTest2 applications with the QuickOPC 5.23(Updated on May 26, 2014) and run both the application at system startup.
2. Again, one application works correctly and the second one throws some other exception.
Exception Text :
System.TypeInitializationException: The type initializer for 'OpcLabs.EasyOpc.DataAccess.EasyDAClient' threw an exception. ---> System.TimeoutException: Timeout waiting for exclusive access on execution mutex "Global\OpcLabs-{76505F20-51A1-43D3-8E2A-6AAEDAB5DBCA}-0xD6CC1689".
at OpcLabs.BaseLib.Threading.ExclusiveExecution..ctor(String regionName, Boolean global, Int32 lockTimeout)
at OpcLabs.BaseLib.Threading.ExclusiveExecutionRegion.WaitBegin(Int32 lockTimeout)
at OpcLabs.BaseLib.Reflection.AssemblyLoader.LoadFromManifestResourceThroughFile(Assembly manifestAssembly, String resourceName, String fileName, Assembly requestingAssembly)
at OpcLabs.BaseLib.Reflection.AssemblyLoader.LoadFromManifestResource(Assembly manifestAssembly, AssemblyName assemblyName, Assembly requestingAssembly)
at OpcLabs.BaseLib.Reflection.AssemblyLoader.InternalLoad(AssemblyName assemblyName, Assembly requestingAssembly)
at OpcLabs.BaseLib.Reflection.AssemblyLoader.LoadExtended(AssemblyName assemblyName, Assembly requestingAssembly)
at OpcLabs.EasyOpc.Assemblies.get_EasyOpcClassicRaw()
at OpcLabs.EasyOpc.DataAccess.EasyDAClient..cctor()
--- End of inner exception stack trace ---
at OpcLabs.EasyOpc.DataAccess.EasyDAClient..ctor()
at OPCTest1.OPCTest1.OPCTest1_Load(Object sender, EventArgs e) in D:\OPCTest1\OPCTest1.vb:line 7
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.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)
Note : I tested in both Windows XP service pack 3 and Windows 7 operating systems. Error occurs frequently in Windows XP and rarely in windows 7.
Please Log in or Create an account to join the conversation.
There has been an error in earlier versions that could cause this. But you need to go for even newer version - please switch to QuickOPC 5.23 or QuickOPC 5.30 (depending on the version of .NET Framework), it should resolve it.
Best regards
Please Log in or Create an account to join the conversation.
If I start all the 6 applications on system startup (that is all the 6 applications starts at the same time), I get the following error.
************** Exception Text **************
System.TypeInitializationException: The type initializer for 'OpcLabs.EasyOpc.DataAccess.EasyDAClient' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Documents and Settings\[user]\Local Settings\Temp\x86_OpcLabs.EasyOpcClassicRaw_5.12.1396.1.dll' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)
File name: 'file:///C:\Documents and Settings\[user]\Local Settings\Temp\x86_OpcLabs.EasyOpcClassicRaw_5.12.1396.1.dll'
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at OpcLabs.BaseLib.AssemblyExtension.LoadFrom(String assemblyFile, String requestingPath)
at OpcLabs.BaseLib.AssemblyLoader.LoadFromManifestResourceThroughFile(Assembly manifestAssembly, String resourceName, String fileName, Assembly requestingAssembly)
at OpcLabs.BaseLib.AssemblyLoader.LoadFromManifestResource(Assembly manifestAssembly, AssemblyName assemblyName, Assembly requestingAssembly)
at OpcLabs.BaseLib.AssemblyLoader.InternalLoad(AssemblyName assemblyName, Assembly requestingAssembly)
at OpcLabs.BaseLib.AssemblyLoader.LoadExtended(AssemblyName assemblyName, Assembly requestingAssembly)
at OpcLabs.EasyOpc.Assemblies.get_EasyOpcClassicNetRaw()
at OpcLabs.EasyOpc.DataAccess.EasyDAClient..cctor()
I had tested this issue with the latest versions "Quick OPC Classic 5.12.1396.1" and "Quick OPC Classic 5.20.1016.1". Still I get the same error.
NOTE: If I run the applications individually, it works well. I get this error when I run two or more applications at the same time. Also this error was not occurred all the time.
Steps to reproduce the above error:
1. Create VB.NET application and add reference EasyOPC.NET Library.
2. At the code behind of the form, copy and paste the following code.
Imports OpcLabs.EasyOpc.DataAccess
Public Class OPCTest1
Public m_objOPCServer As EasyDAClient
Private Sub OPCTest1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
m_objOPCServer = New EasyDAClient
End Sub
End Class
3. In the same way create another VB.NET application 'OPCTest2' and follow the same procedure.
4.Copy the shortcut of OPCTest1 and OPCTest2 applications under the Starup folder on windows server 2008 R2 / Windows 7 / XP.
5. Restart your machine.
Note : The error raises at the line 'm_objOPCServer = New EasyDAClient'.
Please Log in or Create an account to join the conversation.
- Forum
- Discussions
- QuickOPC-Classic in .NET
- General Issues, Building
- System.TypeInitializationException: The type initializer for 'OpcLabs.EasyOpc.DataAccess.EasyDAClient' threw an exception