【发布时间】:2019-01-17 21:28:12
【问题描述】:
在 .NET 核心项目中添加 WCF 时遇到问题。
当我过去使用 .net 时,我可以在 web.config 中添加多个环境,这样我就可以在运行时加载正确的 Web 服务(Dev、Rec、Prod)。
当我将 WCF 服务的引用添加为连接服务时,.net 核心项目中的问题它创建了一个文件 ConnectedService.json,其中包含 WCF 服务的 URL。
{
"ProviderId": "Microsoft.VisualStudio.ConnectedService.Wcf",
"Version": "15.0.20406.879",
"GettingStartedDocument": {
"Uri": "https://go.microsoft.com/fwlink/?linkid=858517"
},
"ExtendedData": {
"Uri": "*****?singleWsdl",
"Namespace": "Transverse.TokenService",
"SelectedAccessLevelForGeneratedClass": "Public",
"GenerateMessageContract": false,
"ReuseTypesinReferencedAssemblies": true,
"ReuseTypesinAllReferencedAssemblies": true,
"CollectionTypeReference": {
"Item1": "System.Collections.Generic.List`1",
"Item2": "System.Collections.dll"
},
"DictionaryCollectionTypeReference": {
"Item1": "System.Collections.Generic.Dictionary`2",
"Item2": "System.Collections.dll"
},
"CheckedReferencedAssemblies": [],
"InstanceId": null,
"Name": "Transverse.TokenService",
"Metadata": {}
}
}
我的问题是如何根据使用的环境加载正确的服务。
注意。
在我的项目中,我没有 appsettings 也没有 web 配置。它是一个 .net core 类库,在 ASP.NET core Application 中作为中间件调用。
【问题讨论】:
标签: c# .net wcf asp.net-core