问题描述
我有Windows 8.1 x64,Visual Studio 2012 x86,IIS 8.5。
I have windows 8.1 x64, Visual Studio 2012 x86, IIS 8.5.
我有Wcf Service Host项目(包含svc文件)
I have Wcf Service Host project (contains svc file)
<%@ ServiceHost Language="C#" Debug="true" Service="WcfServiceImplementation.MyService" %>
我有Wcf Service实施项目。
I have Wcf Service implementation project.
在IIS中托管的Wcf服务
Wcf Service hosted in IIS
我有2个程序集:WcfService.Host.dll和WcfServiceImplementation.dll
I have 2 assemblies: WcfService.Host.dll and WcfServiceImplementation.dll
WcfServiceImplementation.dll中的这段代码:
This code in WcfServiceImplementation.dll:
1)
Assembly.GetEntryAssembly()
获取空值。
2)
Assembly.GetExecutingAssembly()
获取WcfServiceImplementation。
gets WcfServiceImplementation.
3)
Assembly.GetCallingAssembly()
获取System.ServiceModel。
gets System.ServiceModel.
如何在执行WcfServiceImplementation程序集的代码中以编程方式获取Service.Host程序集的位置?
How can I get Service.Host assembly location programatically in the code that execute WcfServiceImplementation assembly?
通常,对于任何Wcf Service或Web应用程序,如何获取主程序集(wcf服务主机,Web应用程序)?
In general, for any Wcf Service or Web Application, how get the "main assembly" (the wcf service host, the web application) ?
我的跟踪(日志):
My trace (log):
ProcessName: w3wp
Is64BitOperatingSystem: True
Is64BitProcess: True
SystemConfigurationFile: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config
ConfigurationFile: C:\TFS\Tests\WcfService\web.config
MainModule.FileName: c:\windows\system32\inetsrv\w3wp.exe
MainModule.ModuleName: w3wp.exe
BaseDirectory: C:\TFS\Tests\WcfService\
ApplicationBase: C:\TFS\Tests\WcfService\
FriendlyName: /LM/W3SVC/2/ROOT-5-130404032112324911
ApplicationName: c36153ea
Code in WcfServiceImplementation assembly:
Assembly.GetEntryAssembly():
GetAssemblyExtendedData. Assembly null
Assembly.GetExecutingAssembly():
Location: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\2090c609\c36153ea\assembly\dl3\92d3ec19\b0fa1582_c649cf01\WcfServiceImplementation.dll
ProcessorArchitecture: MSIL
Assembly.GetCallingAssembly():
Location: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll
ProcessorArchitecture: MSIL
建议?
推荐答案
这个在WCF服务中为我工作:
This one worked for me in WCF service:
例如:
您可以看到将文件复制到子目录下,解决方案中的这些文件被标记为复制到输出目录的构建操作,该文件将复制目录以及文件(对于我而言,这是我所需要的,否则请使用资源作为项目中的链接)
You can see the files are copied under sub-directory and these files in the solution are marked as build-action "Copy to output directory" which copies directory as well as files (which I wanted for my case, otherwise use resources as the link in the project).
这篇关于使用SvcImplementation程序集获取SvcHost程序集位置(路径)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!