【发布时间】:2016-05-24 21:31:29
【问题描述】:
我确实想将本机 DLL 导入 Microsoft 服务结构服务。这可能吗?如果是这样,我该如何实现?我想我被困在如何告诉部署也部署本机 DLL 以便稍后在运行时导入它。目前我收到一个运行时错误,即找不到 dll。由于整个应用程序都部署到了服务结构集群,我想我还需要以某种方式在那里获取所需的本机 DLL。
非常感谢任何帮助!提前谢谢!
最好的问候
马里奥
编辑: 抱歉,关于我的方法和错误,我可能需要的信息很少。我尝试像这样在我的 C# 服务中导入本机 DLL:
[DllImport("Plugin.dll",
EntryPoint = "DoSomeStuff",
CallingConvention = CallingConvention.Cdecl)]
public static extern int DoSomeStuff();
然后在StatelessService的继承函数RunAsync中调用导入的函数:
protected override async Task RunAsync(CancellationToken cancellationToken)
{
DoSomeStuff();
}
我的第一个方法是简单地将所需的 Plugin.dll 文件放入其他可执行文件所在的 bin 文件夹中。但是它们要么没有被移动到集群中,要么运行时找不到。
在运行时我确实得到了以下异常:
System.DllNotFoundException: Die DLL \"Plugin.dll\": Das angegebene Modul wurde nicht gefunden. (Ausnahme von HRESULT: 0x8007007E) kann nicht geladen werden.
bei DoSomeStuff()
bei Application.<RunAsync>d__2.MoveNext() in C:\\SolutionPath\\ProjectPath\\Application.cs:Zeile 45.
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei Microsoft.ServiceFabric.Services.Runtime.StatefulServiceReplicaAdapter.<ExecuteRunAsync>d__e.MoveNext()"
很抱歉出现德语错误信息(原文),我试着翻译一下:
System.DllNotFoundException: The DLL \"Plugin.dll\": The specified Module was not found. (Exception of HRESULT: 0x8007007E) cannot be loaded.
at DoSomeStuff()
at Application.<RunAsync>d__2.MoveNext() in C:\\SolutionPath\\ProjectPath\\Application.cs:Zeile 45.
--- End of stack trace of the exception origin, where the exception was raised ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ServiceFabric.Services.Runtime.StatefulServiceReplicaAdapter.<ExecuteRunAsync>d__e.MoveNext()"
【问题讨论】:
-
考虑尝试包含有关错误的一些信息以及任何可能使人们更容易提供帮助的代码 sn-ps
标签: c# dll azure-service-fabric