Wcf 使用SvcHost实现程序集获取SvcHost程序集位置(路径)

Wcf 使用SvcHost实现程序集获取SvcHost程序集位置(路径),wcf,.net-assembly,servicehost,Wcf,.net Assembly,Servicehost,我有windows 8.1 x64、Visual Studio 2012 x86和IIS 8.5 我有Wcf服务主机项目(包含svc文件) 获取空值 (二) 获取WcfServiceImplementation (三) 获取System.ServiceModel 如何在执行WcfServiceImplementation程序集的代码中以编程方式获取Service.Host程序集位置 通常,对于任何Wcf服务或Web应用程序,如何获取“主程序集”(Wcf服务主机,Web应用程序) 我的跟踪(日志)

我有windows 8.1 x64、Visual Studio 2012 x86和IIS 8.5

我有Wcf服务主机项目(包含svc文件)

获取空值

(二)

获取WcfServiceImplementation

(三)

获取System.ServiceModel

如何在执行WcfServiceImplementation程序集的代码中以编程方式获取Service.Host程序集位置

通常,对于任何Wcf服务或Web应用程序,如何获取“主程序集”(Wcf服务主机,Web应用程序)

我的跟踪(日志):


建议?

这一条在WCF服务中对我很有用:

AppDomain.CurrentDomain.RelativeSearchPath

例如:

字符串certFilePath= AppDomain.CurrentDomain.RelativeSearchPath+“\”+ 证书\目录\名称+“\”+证书\文件\名称

您可以看到文件被复制到子目录下,解决方案中的这些文件被标记为构建操作“复制到输出目录”,该操作复制目录以及文件(我想在我的案例中使用这些文件,否则将资源用作项目中的链接)

<%@ ServiceHost Language="C#" Debug="true" Service="WcfServiceImplementation.MyService"  %>
Assembly.GetEntryAssembly()
Assembly.GetExecutingAssembly()
Assembly.GetCallingAssembly()
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