我有Windows 8.1 x64,Visual Studio 2012 x86,IIS 8.5。
我有Wcf服务主机项目(包含svc文件)
<%@ ServiceHost Language="C#" Debug="true" Service="WcfServiceImplementation.MyService" %>
我有Wcf服务实施项目。
在IIS中托管的Wcf服务
我有2个程序集:WcfService.Host.dll和WcfServiceImplementation.dll
WcfServiceImplementation.dll中的此代码:
1)
Assembly.GetEntryAssembly()
变为空。
2)
Assembly.GetExecutingAssembly()
获取WcfServiceImplementation。
3)
Assembly.GetCallingAssembly()
获取System.ServiceModel。
如何在执行WcfServiceImplementation程序集的代码中以编程方式获取Service.Host程序集位置?
通常,对于任何Wcf服务或Web应用程序,如何获得&#34;主程序集&#34; (wcf服务主机,Web应用程序)?
我的追踪(日志):
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
建议?
答案 0 :(得分:0)
这个在WCF服务中为我工作:
AppDomain.CurrentDomain.RelativeSearchPath
例如:
string certFilePath = AppDomain.CurrentDomain.RelativeSearchPath +&#34; \&#34; + CERTIFICATES_DIRECTORY_NAME +&#34; \&#34; + CERTIFICATE_FILE_NAME;
您可以看到文件被复制到子目录下,解决方案中的这些文件被标记为build-action&#34;复制到输出目录&#34;它复制目录和文件(我想要的是我的情况,否则使用资源作为项目中的链接)。