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));
}
}
}