我有一个尝试加载DLL的服务。我的服务在我的开发笔记本电脑上工作正常,但在尝试使用其他两台笔记本电脑时,我得到以下例外:
The type initializer for "NanoProtoApi.Interop" threw an exception. --->System.Exception: LoadLibrary failed: C:\Program Files\Proj\x64\Nanomsg.dll.
我检查了dll的位置,它肯定在那里。我不知道发生了什么事。有谁知道发生了什么以及如何解决这个问题?
以下是异常堆栈跟踪:
System.TypeInitializationException: The type initializer for 'NanoProtoApi.Interop' threw an exception. ---> System.Exception: LoadLibrary failed: C:\Program Files\Proj\x64\Nanomsg.dll
at NanoProtoApi.NanomsgLibraryLoader.LoadWindowsLibrary(String libName, SymbolLookupDelegate& symbolLookup)
at NanoProtoApi.Interop..cctor()
--- End of inner exception stack trace ---
at NanoProtoApi.NanomsgSocketBase..ctor(Domain domain, Protocol protocol)
at NanoProtoApi.Protocols.SubscribeSocket..ctor()
at MK18.ATR.GATR.GatrProcessingClient.<>c.<runDetectReportFilteredTask>b__26_0() in C:\Users\user\Documents\MK 18\src\coin\mk18atr\project\Utilities\GatrProcessingClient.cs:line 238
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MK18.ATR.GATR.GatrProcessingClient.<SubscribeToDetectReportFiltered>d__25.MoveNext() in C:\Users\user\Documents\MK 18\src\coin\mk18atr\project\Utilities\GatrProcessingClient.cs:line 219
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_1(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
答案 0 :(得分:1)
这通常意味着库中的某些类在静态构造期间有三个异常。由于异常发生,加载失败。通常,库应考虑到这一点并在加载时处理故障。 由于这对您有用,并且堆栈跟踪中存在一些网络通信痕迹,我猜测尝试访问某些远程资源时出现问题。此组件是否需要连接到其他计算机?可以从服务器到达那些机器吗?