【问题标题】:Hosting WCF Service using unmanaged DLLs使用非托管 DLL 托管 WCF 服务
【发布时间】:2012-01-01 17:38:37
【问题描述】:

我有一个托管 DLL,它在内部引用了几个非托管 DLL。添加此托管 DLL 作为对我的 WCF 服务项目的引用。但是,必须手动将非托管 DLL 复制到我的项目的构建输出路径中。它们不能在 Visual Studio 中被引用。

如果我尝试在 Visual Studio 的 WCF 服务主机中运行我的服务 DLL,后者会崩溃而没有任何异常并自动重新启动。如果我尝试在 IIS 中托管服务 DLL,则适用示例。尝试在 IIS 中托管时,我能够捕获 WERReportMetadata 崩溃日志之一,并且 ProblemSignatures 说:

<ProblemSignatures>
    <EventType>CLR20r3</EventType>
    <Parameter0>webdev.webserver40.exe</Parameter0>
    <Parameter1>10.0.0.0</Parameter1>
    <Parameter2>4d5f345a</Parameter2>
    <Parameter3>GTAPIASM</Parameter3>
    <Parameter4>2.0.5.0</Parameter4>
    <Parameter5>4e9254a5</Parameter5>
    <Parameter6>166</Parameter6>
    <Parameter7>23</Parameter7>
    <Parameter8>System.AccessViolationException</Parameter8>
  </ProblemSignatures> 

这是什么意思,我能做些什么?任何有关使用非托管 DLL 托管 WCF 的参考资料也将很有用。

编辑 1: 将非托管 DLL 复制到 %systemroot%\syswow64 允许我使用 Visual Studio WCF 服务主机托管我的服务。我从here 那里得到了提示。但是,这并不能阻止 WebDev.WebDServer40.exe 崩溃。

编辑 2 这是从事件查看器捕获的 .NET 运行时错误:

应用程序:WebDev.WebServer40.exe 框架版本:v4.0.30319 说明:进程因未处理的异常而终止。 异常信息:System.TypeInitializationException 堆栈:在 System.RuntimeMethodHandle._InvokeConstructor(System.IRuntimeMethodInfo, System.Object[], System.SignatureStruct ByRef, System.RuntimeType) 在 System.RuntimeMethodHandle.InvokeConstructor(System.IRuntimeMethodInfo, System.Object[], System.SignatureStruct, System.RuntimeType) 在 System.Reflection.RuntimeConstructorInfo.Invoke(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo) 在 System.ServiceModel.Description.ServiceDescription.CreateImplementation(System.Type) 在 System.ServiceModel.Description.ServiceDescription.SetupSingleton(System.ServiceModel.Description.ServiceDescription, System.Object,布尔值)在 System.ServiceModel.Description.ServiceDescription.GetService(System.Type) 在 System.ServiceModel.ServiceHost.CreateDescription(System.Collections.Generic.IDictionary`2 ByRef)在 System.ServiceModel.ServiceHostBase.InitializeDescription(System.ServiceModel.UriSchemeKeyedCollection) 在 System.ServiceModel.ServiceHost.InitializeDescription(System.Type, System.ServiceModel.UriSchemeKeyedCollection)在 System.ServiceModel.ServiceHost..ctor(System.Type, System.Uri[]) 在 System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(System.Type, System.Uri[]) 在 System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(System.String, System.Uri[]) 在 System.ServiceModel.ServiceHostingEnvironment+HostingManager.CreateService(System.String) 在 System.ServiceModel.ServiceHostingEnvironment+HostingManager.ActivateService(System.String) 在 System.ServiceModel.ServiceHostingEnvironment+HostingManager.EnsureServiceAvailable(System.String) 在 System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(System.String) 在 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest() 在 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest() 在 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(System.Object) 在 System.Runtime.IOThreadScheduler+ScheduledOverlapped.IOCallback(UInt32, UInt32,System.Threading.NativeOverlapped*) 在 System.Runtime.Fx+IOCompletionThunk.UnhandledExceptionFrame(UInt32, UInt32,System.Threading.NativeOverlapped*) 在 System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)

编辑 2:

原来我必须始终以管理员身份运行 Visual Studio。这样就消除了之前的错误。

谢谢。

【问题讨论】:

    标签: iis-7 unmanaged wcf wcf-hosting


    【解决方案1】:

    我需要将非托管 DLL 添加到 %systemroot%\syswow64。这样做并且可以在 Visual Studio 的 WCF 服务主机以及 ASP 开发服务器中运行我的服务。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-18
      • 1970-01-01
      • 1970-01-01
      • 2010-10-14
      • 2017-10-16
      • 2011-10-01
      相关资源
      最近更新 更多