【发布时间】:2017-03-01 11:25:31
【问题描述】:
所以我在本地创建服务时遇到问题,我的应用程序作为 WebJob。好像我阅读了所有谷歌,但我找不到解决方案。 This one here 对我来说不算数,因为它是关于身份验证的。
所以,我的电脑上有一个 C# 控制台应用程序,其中包含许多引用、ddls 和大量计算,它们像服务一样运行。主函数,如下所示:
static void Main(string[] args)
{
string baseAddress = "http://127.0.0.1:80";
Console.WriteLine(baseAddress);
if (args.Count() > 0 && !string.IsNullOrEmpty(args[0]))
baseAddress = args[0];
SelfHostServer server = new SelfHostServer(); //using Microsoft.Owin;
server.Start(baseAddress);
}
然后我在 Azure AppService 上发布了一个 nodeJs 应用程序。基本上,我需要它来调用 C# 服务并获得结果响应。出于这个原因,我试图用我的 C# 应用程序创建一个 WebJob。我发布它并尝试运行它,但我得到(这个错误是来自天蓝色的门户控制台):
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.HttpListenerException: Access is denied
at System.Net.HttpListener.SetupV2Config()
at System.Net.HttpListener.Start()
at Microsoft.Owin.Host.HttpListener.OwinHttpListener.Start(HttpListener listener, Func`2 appFunc, IList`1 addresses, IDictionary`2 capabilities, Func`2 loggerFactory)
at Microsoft.Owin.Host.HttpListener.OwinServerFactory.Create(Func`2 app, IDictionary`2 properties)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create(IAppBuilder builder)
at Microsoft.Owin.Hosting.Engine.HostingEngine.StartServer(StartContext context)
at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)
at Microsoft.Owin.Hosting.Starter.DirectHostingStarter.Start(StartOptions options)
at Microsoft.Owin.Hosting.Starter.HostingStarter.Start(StartOptions options)
at Microsoft.Owin.Hosting.WebApp.StartImplementation(IServiceProvider services, StartOptions options)
at Microsoft.Owin.Hosting.WebApp.Start(StartOptions options)
at Microsoft.Owin.Hosting.WebApp.Start[TStartup](StartOptions options)
at Avilda.Klevas.Core.Server.SelfHostServer.Start(String baseAddress)
at klevas.webapistart.Program.Main(String[] args)
看来是端口的问题,但我无论如何都找不到合适的。我可以运行其他 exe,但不能运行听者的。我不在乎 C# 应用程序是否无法从外部访问,我只希望这两个能够通信。有任何想法吗?或者其他解决方案(VM除外)?
【问题讨论】:
-
我现在设法在我的计算机上本地获取此错误。然后通过以管理员身份运行 Visual Studio 来解决它。所以 idk,也许有办法以管理员身份运行 WebJob?
标签: c# node.js azure port azure-webjobs