gpt4 book ai didi

c# - 仅在 Azure 应用服务中出现错误 : Object reference not set to an instance of an object

转载 作者:太空宇宙 更新时间:2023-11-03 12:45:43 25 4
gpt4 key购买 nike

我有一个持续运行的作业(服务),我正在尝试将其作为应用服务部署到 Azure。它是在 Visual Studio 中创建为典型的控制台应用程序,然后使用 TopShelf 作为服务运行。

目前,我们正在将此服务部署到 Rack Space 中托管的 Windows 盒子上。但我们正在从该模型转向 Azure。无论是在我的本地计算机上调试,还是在 Rack Space Windows 服务器上,它都运行完美。但是当我部署到 Azure 时,出现对​​象引用错误。

此服务的目的非常简单:在 Azure 服务总线中查询消息(如果有),将它们放入列表中,然后将该列表交给另一个处理它们的类。就是这样。服务总线的实际连接并未在该项目或类中完成。为此,它依赖于 QueueAccess,这是一个单独的类。

public class MessageQueueQuery : IMessageQueueQuery
{
...
private QueueAccess queueAccess; // QueueAccess is a reference to another project.

public void Start()
{
...
queueAccess = new QueueAccess();
...

// Go get the messages
try
{
messageList = queueAccess.GetMessageCollection(); // <-- ERROR IS HERE
}
catch (Exception ex)
{
_log.ErrorFormat("Error in retreiving a list of messages from queue.", ex);
}

同样,这适用于除作为应用服务部署到 Azure 之外的所有实例。全面相同的代码。我在想也许我部署错了?由于某种原因,QueueAccess 的 .dll 没有随部署一起发送?尽管当我通过 FTP 登录时,我可以看到它与其余文件一起放在那里。

这是完整的日志条目:

2016-05-20T20:56:08  PID[10568] Information    at XXXXXX.Queue.Core.MessageQueueQuery.ProcessMessages() in C:\XXXXXXGit\XXXXXX\Main\XXXXXX.Queue.Core\MessageQueueQuery.cs:line 108

2016-05-20T20:56:08 PID[10568] Information 2016-05-20 20:56:08,156 [5] ERROR XXXXXX.Queue.WindowsService.Bootstrapper [(null)] - Error in retrieving a list of messages from queue.

我不确定为什么它不起作用。

最佳答案

我不是 TopShelf 用户,但是:

在 Rackspace 中,我猜您的应用程序在 VM (IaaS) 中运行。在应用服务中,您的应用程序在 PaaS 中运行,而不是在 IaaS 中运行。

  1. 您可以尝试将应用程序部署到 Azure VM。

  2. 或检查 TopShelf 与 Azure PaaS 的兼容性。他们似乎为 worker 角色提供了解决方案(= Azure PaaS v1 的一部分)https://github.com/Topshelf/Topshelf.Azure

  3. 您还可以检查 native Azure PaaS v2 解决方案来运行 Web 作业 https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/

关于c# - 仅在 Azure 应用服务中出现错误 : Object reference not set to an instance of an object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37394930/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com