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.

× If you are developing in .NET, but are using the OPC-UA (OPC Unified Architecture), please post in the QuickOPC-UA category instead.

After updating to 5.71 (Nugget Package) I get TypeInitializationException Error

More
15 Nov 2023 11:16 #12367 by support
Hello.

Please send over the whole minimal project to reproduce it. Your code appears fine; the fact that the error appears probably has to do with Blazor etc.

Regards

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

More
15 Nov 2023 10:58 #12365 by mut9bu
Error: System.TypeInitializationException: The type initializer for 'OpcLabs.BaseLib.Runtime.InteropServices.ComManagement' threw an exception.
---> System.TypeInitializationException: The type initializer for 'OpcLabs.BaseLib.Extensions.Hosting.ApplicationInstance' threw an exception.
---> System.TypeInitializationException: The type initializer for 'OpcLabs.BaseLib.Internal.Initialize' threw an exception.
---> System.TypeInitializationException: The type initializer for 'Configuration' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'Blazorise.Licensing, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Blazorise.Licensing, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null'
at System.ModuleHandle.ResolveType(QCallModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctorWithParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)
at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](Assembly element)
at OpcLabs.BaseLib.Diagnostics.Managed.TraceSourceManager.GetTraceSourceAttributes(Assembly assembly)
at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
at OpcLabs.BaseLib.Collections.Generic.Extensions.IEnumerableExtension.ForAll[TSource](IEnumerable`1 source, Action`1 action)
at OpcLabs.BaseLib.Collections.ObjectModel.Extensions.KeyedCollectionExtension.WeakAddRange[TKey,TValue](KeyedCollection`2 keyedCollection, IEnumerable`1 items)
at OpcLabs.BaseLib.Diagnostics.Managed.TraceSourceManager.GetTraceSourceAttributeKeyedCollection()
at OpcLabs.BaseLib.Diagnostics.Managed.TraceSourceManager.FindTraceSourceAttribute(String traceSourceName)
at OpcLabs.BaseLib.Diagnostics.Managed.TraceSourceManager.CreateTraceSource(String name)
at OpcLabs.BaseLib.Diagnostics.Managed.TraceSourceManager.GetTraceSource(String name)
at OpcLabs.BaseLib.Diagnostics.Managed.TraceSourceManager.ProtectedGetTraceSource(String name)
at OpcLabs.BaseLib.Diagnostics.TraceSources.Configuration..cctor()
--- End of inner exception stack trace ---
at OpcLabs.BaseLib.Diagnostics.TraceSources.Configuration.get_Retrieve()
at OpcLabs.BaseLib.Configuration.ConfigurationManagerUtilities.TraceGetSetting[TValue](String name, TValue value, Sign status)
at OpcLabs.BaseLib.Configuration.ConfigurationManagerUtilities.PassThroughTraceGetSetting[TValue](String name, TValue value, Sign status)
at OpcLabs.BaseLib.Configuration.ConfigurationManagerUtilities.GetEnumSetting[TEnum](String name, TEnum defaultValue)
at OpcLabs.BaseLib.Internal.Initialize..cctor()
--- End of inner exception stack trace ---
at OpcLabs.BaseLib.Internal.Initialize`1..ctor(Func`1 valueFactory, LazyThreadSafetyMode threadSafetyMode)
at OpcLabs.BaseLib.Internal.Initialize`1..ctor(Func`1 valueFactory)
at OpcLabs.BaseLib.Extensions.Hosting.ApplicationInstance..ctor()
at OpcLabs.BaseLib.Extensions.Hosting.ApplicationInstance..cctor()
--- End of inner exception stack trace ---
at OpcLabs.BaseLib.Runtime.InteropServices.ComManagement..cctor()
--- End of inner exception stack trace ---
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.OptionalCreateComSecurityInitializingClient(IEasyDAClient client)
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.CreateInnerClient2(Boolean onlyForInformation)
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.CreateInnerClient()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.get_InnerClient()
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.ReadMultipleItems(DAReadItemArguments[] argumentsArray)
at OpcLabs.EasyOpc.DataAccess.IEasyDAClientExtension.ReadMultipleItems(IEasyDAClient client, ServerDescriptor serverDescriptor, DAItemDescriptor[] itemDescriptorArray, DAReadParameters readParameters)
at OpcLabs.EasyOpc.DataAccess.IEasyDAClientExtension.ReadMultipleItems(IEasyDAClient client, ServerDescriptor serverDescriptor, DAItemDescriptor[] itemDescriptorArray)
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.<>c.<.cctor>b__111_0()
at OpcLabs.BaseLib.Internal.Once.<>c__DisplayClass0_0.<.ctor>b__0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at OpcLabs.BaseLib.Internal.Lazy2`1.<Kick>b__4_0()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)


My code:

public void Browse_Servers()
{
var client = new EasyDAClient();
ServerElementCollection serverElements;
try
{
serverElements = client.BrowseServers(TagService.IP_Win_List);
}
catch (OpcException opcException)
{
Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
return;
}

foreach (ServerElement serverElement in serverElements)
{
Console.WriteLine($"ServerElements(\"{serverElement.ClsidString}\").ProgId: {serverElement.ProgId}");
using (StreamWriter sw = File.AppendText(CommonClass.error_path))
{
sw.WriteLine($"ServerElements(\"{serverElement.ClsidString}\").ProgId: {serverElement.ProgId}" + " " + Convert.ToString(DateTime.Now));

}
}
}

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

Moderators: support
Time to create page: 0.063 seconds