【问题标题】:Visual studio 2015 and 2017 do not start IIS Express 64 bit versionVisual Studio 2015 和 2017 不启动 IIS Express 64 位版本
【发布时间】:2017-05-09 09:50:22
【问题描述】:

即使我已将 Visual Studio 设置为运行 IIS Express 64 位,它仍会继续启动 IIS Express 32 位。我需要运行 64 位版本,因为我有一些仅适用于 64 位主机环境的参考。

  • 我的项目是基于模板“ASP.NET Core Web 应用程序(.NET 框架)”和,
  • 我已经设置了 Visual Studio(2015 和 2017 RC)来使用 IIS Express 64 位通过转到工具/选项/“项目和解决方案”/ “Web 项目”并选中“使用 64 位版本的 用于网站和项目的 IIS Express”。

Visual Studio 2015(Enterprise 14.0.25431.01 Update 3)和 2017 RC(Professional public.d15rel/15.0.26014.0)两个版本都会出现此问题

我无法使用本地 IIS,因为我使用的是 ASP.NET Core。

在最坏的情况下,我可以手动运行 IIS Express,但无法成功。我能够运行 IIS,但无法运行网站或无法调试。 (我用这个页面寻求帮助https://host4asp.net/run-iis-express-from-the-command-line/

其他信息:

  • 迫使我尝试使用 IIS Express 64 位的错误是 关注

System.AggregateException:发生一个或多个错误。 ---> System.NotSupportedException:分区路由信息不能 在 32 位进程中运行时从查询中提取。去完成 您的查询并避免此异常,请确保您的主机进程是 64 位。对于可执行应用程序,这可以通过取消选中来完成 项目属性窗口中的“首选 32 位”选项,在 构建选项卡。对于基于 VSTest 的测试项目,这可以通过 选择测试->测试设置->默认处理器架构为 X64, 从 Visual Studio 测试菜单选项。对于本地部署的 ASP.NET Web 应用程序,这可以通过选中“使用 64 位版本 用于网站和项目的 IIS Express”,在 工具->选项->项目和解决方案->Web项目。 在 Microsoft.Azure.Documents.Query.QueryPartitionProvider.GetPartitionedQueryExecutionInfo(SqlQuerySpec querySpec, PartitionKeyDefinition partitionKeyDefinition, Boolean requireFormattableOrderByQuery, Boolean isContinuationExpected) 在 Microsoft.Azure.Documents.Query.DocumentQueryExecutionContextBase.d__0.MoveNext() --- 从先前抛出异常的位置结束堆栈跟踪 --- 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)在 Microsoft.Azure.Documents.Query.DocumentQueryExecutionContextFactory.d__3.MoveNext() --- 从先前抛出异常的位置结束堆栈跟踪 --- 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)在 Microsoft.Azure.Documents.Linq.DocumentQuery1.<CreateDocumentQueryExecutionContextAsync>d__12.MoveNext() --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task1.GetResultCore(布尔 waitCompletionNotification)在 System.Threading.Tasks.Task1.get_Result() at Microsoft.Azure.Documents.Linq.DocumentQuery1.d__b.MoveNext() 在 System.Collections.Generic.List1..ctor(IEnumerable1 集合)
在 System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at TestWebWithDocDb.Controllers.TestController.tester3() at lambda_method(Closure , Object , Object[] ) at Microsoft.AspNetCore.Mvc.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__27.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__25.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextResourceFilter>d__22.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResourceExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeAsync>d__20.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext() ---> (Inner Exception #0) System.NotSupportedException: Partition routing information cannot be extracted from the query when running in a 32-bit process. To complete your query and avoid this exception, ensure that your host process is 64-bit. For Executable applications, this can be done by unchecking the "Prefer 32-bit" option in the project properties window, on the Build tab. For VSTest based test projects, this can be done by selecting Test->Test Settings->Default Processor Architecture as X64, from Visual Studio Test menu option. For locally deployed ASP.NET Web applications, this can be done by checking the "Use the 64 bit version of IIS Express for web sites and projects", under Tools->Options->Projects and Solutions->Web Projects. at Microsoft.Azure.Documents.Query.QueryPartitionProvider.GetPartitionedQueryExecutionInfo(SqlQuerySpec querySpec, PartitionKeyDefinition partitionKeyDefinition, Boolean requireFormattableOrderByQuery, Boolean isContinuationExpected) at Microsoft.Azure.Documents.Query.DocumentQueryExecutionContextBase.<GetPartitionedQueryExecutionInfoAsync>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.Documents.Query.DocumentQueryExecutionContextFactory.<CreateDocumentQueryExecutionContextAsync>d__3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.Documents.Linq.DocumentQuery1.d__12.MoveNext()

  • 如果我将 Web 项目设置为目标平台 x64,则 Web 项目 在 Program 类的 host.run() 上抛出一个错误:

“试图加载格式不正确的程序。
(来自 HRESULT 的异常:0x8007000B)”。

我猜这是因为 我正在尝试在 32 位平台上运行 64 位版本(IIS 快递)。

我附上了一个示例代码。 tester 操作有效,但 tester3 操作在“var list = res.ToList();”行产生错误。

using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Documents.Client;
using System;
using System.Linq;
using SomeNamespace;
using Newtonsoft.Json;
using System.Globalization;

namespace TestWebWithDocDb.Controllers
{
    public class TestController : Controller
    {
        public IActionResult tester()
        {


            var client = new DocumentClient(new Uri("https://xxxxxxxxxxxxxx.documents.azure.com:443/"), "xxxxxxxxxxxxxx");

            //var query = "Select * from Main";
            var res = client.CreateDatabaseQuery().Where(db => db.Id.Equals("xxxxxxxxxxxxxx")).AsEnumerable().FirstOrDefault();


            return this.Content("OK", "text/plain");
        }
        public IActionResult tester3()
        {
            var Query = "Select * From Main ";

            var client = new DocumentClient(new Uri("https://xxxxxxxxxxxxxx.documents.azure.com:443/"), "xxxxxxxxxxxxxx");

            var databases = client.CreateDatabaseQuery().ToList();
            var a = client.AuthKey;
            var _db = client.CreateDatabaseQuery().Where(db => db.Id.Equals("xxxxxxxxxxxxxx")).AsEnumerable().FirstOrDefault();
            if (_db == null)
            {
                throw new ApplicationException("no db");
            }

            var _col = client.CreateDocumentCollectionQuery("dbs/" + _db.Id).Where(c => c.Id.Equals("Main")).AsEnumerable().FirstOrDefault();
            if (_col == null)
            {
                throw new ApplicationException("no collection");
            }

            var _path = "dbs/" + _db.Id + "/colls/" + _col.Id;


            var res = client.CreateDocumentQuery<BreederDocument>(_path, Query);
            var list = res.ToList();
            var resOut = list;
            return this.Json(resOut);

        }
    }
}




namespace SomeNamespace
{
    public abstract class DocumentBase : Microsoft.Azure.Documents.Resource
    {

        protected String _changedBy;
        protected DateTime _created;
        protected Byte _DType;
        protected DateTime _modified;
        protected String _name;
        protected Guid _UID;
        protected String _version;


        /// <summary> Constructor </summary>
        public DocumentBase()
        {
            _changedBy = ""; 
            _created = DateTime.Now;
            _DType = 0;
            _modified = DateTime.Now;
            _name = "unknown";
            base.Id = Guid.NewGuid().ToString();
            _version = "1.0";
        }

        [JsonProperty("changedBy", Order = 202)]
        public string ChangedBy
        {
            get { return _changedBy; }
            set { _changedBy = value; }
        }

        [JsonProperty("created", Order = 200)]
        public DateTime Created
        {
            get { return _created; }
            set { _created = value; }
        }

        [JsonProperty("DType", Order = 0), JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
        public Byte DType
        {
            get { return _DType; }
            set { _DType = value; }
        }

        [JsonProperty("id", Order = 3)]
        public string id
        {
            get { return base.Id; }
            set
            {
                Guid UID = Guid.Empty;
                if (!Guid.TryParse(value, out UID))
                {
                    throw new Exception("Cannot set id: value is not a valid GUID");
                }
                else
                {
                    base.Id = UID.ToString();
                }

            } // end set
        } // end property


        [JsonProperty("modified", Order = 201)]
        public DateTime Modified
        {
            get { return _modified; }
            set { _modified = value; }
        }

        [JsonProperty("name", Order = 10)]
        virtual public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        [JsonIgnore]
        public Guid UID
        {
            get { return Guid.Parse(id); }
        }

        [JsonProperty("version", Order = 1)]
        public string Version
        {
            get { return _version; }
            set { _version = value; }
        }


    } // end class


    public class BreederDocument : DocumentBase
    {

        TextInfo tInfo;

        public BreederDocument() : base()
        {
            tInfo = CultureInfo.CurrentCulture.TextInfo;
            _DType = 10;
            //_AccountID = Nothing
        }

        /// <summary> The AccountID for this breeder </summary>
        /// <returns></returns>
        [JsonProperty("accountID", Order = 9)]
        public string AccountID
        {
            get { return _AccountID; }
            private set { _AccountID = value; }
        }
        private string _AccountID;

        [JsonProperty("name", Order = 10)]
        public override string Name
        {
            get { return _name; }
            set
            {
                if (value != null) { value = tInfo.ToTitleCase(value); };
                if (_name != value)
                {
                    _name = value;
                }
            }
        }

        /// <summary> Short Name </summary>
        /// <returns></returns>
        [JsonProperty("shortName", NullValueHandling = NullValueHandling.Ignore, Order = 11)]
        public string ShortName
        {
            get { return _ShortName; }
            set
            {
                if (value != null) { value = tInfo.ToTitleCase(value); };
                if (_ShortName != value)
                {
                    _ShortName = value;
                }
            }
        }
        private string _ShortName;

        /// <summary> Kennel Name </summary>
        /// <returns></returns>
        [JsonProperty("kennelName", NullValueHandling = NullValueHandling.Ignore, Order = 12)]
        public string KennelName
        {
            get { return _KennelName; }
            set
            {
                if (value != null) { value = tInfo.ToTitleCase(value); };
                if (_KennelName != value)
                {
                    _KennelName = value;
                }
            }
        }
        private string _KennelName;





        [JsonProperty("webSite", Order = 22)]
        public string WebSite
        {
            get { return _WebSite; }
            set { _WebSite = value; }
        }

        private string _WebSite;
        [JsonProperty("sponsored", NullValueHandling = NullValueHandling.Ignore, Order = 30)]
        public string Sponsored
        {
            get { return _Sponsored; }
            set { _Sponsored = value; }
        }
        private string _Sponsored;



        [JsonProperty("initialPassword", NullValueHandling = NullValueHandling.Ignore, Order = 50)]
        public string InitialPassword
        {
            get { return _InitialPassword; }
            set { _InitialPassword = value; }
        }
        private string _InitialPassword = null;



    } // end class

} // end namespace

解决方案中安装的 NuGet 包: NuGet packages installed in solution

【问题讨论】:

  • 您使用的是哪个版本的 Microsoft.Azure.DocumentDB.Core?我假设它是 1.0.0(几天前发布)。我知道如果您在 Azure 网站上部署此应用程序,您可能会遇到此问题,因为 Azure 网站目前仅支持 .NET Core 应用程序的 32 位主机,但当您将其设置为 IIS Express 时,它应该可以按预期工作64位(如您所述)。您确定您是针对本地 IIS Express 而不是在 Azure 网站上运行的吗?不管怎样,请给我一个有这个问题的示例代码,我会尝试在我的最后重现它。
  • 嗨 Rajesh,我使用的是 Microsoft.Azure.DocumentDB 版本 1.11.1(不是 CORE 版本)。我意识到我在解释问题时犯了一个错误。我使用的是模板项目“ASP.NET Core Web Application (.NET Framework)”,而不是 .NET Core。我在问题的底部添加了示例代码。谢谢。

标签: visual-studio azure-web-app-service iis-express azure-cosmosdb


【解决方案1】:

System.NotSupportedException:在 32 位进程中运行时,无法从查询中提取分区路由信息。

根据您提供的错误,我假设您的收集模式是分区的。关于这个错误的一些详细信息,你可以在 git 上参考这个issue。如果您不使用 DocumentDb 中的分区路由功能,您可以尝试更改代码并提供 FeedOptions 以禁用 EnableCrossPartitionQuery

【讨论】:

  • Bruce,我们使用的是单分区集合,我还添加了选项 FeedOptions defaultOptions = new FeedOptions { EnableCrossPartitionQuery = false };但它仍然会产生相同的错误。但是这里的主要问题是VS没有启动64位版本的IIS express。对这个问题有任何想法吗?感谢您的帮助。
  • 我已经在本地测试了这个问题,发现 IIS Express 将始终以 32 位运行 NETCore Web 应用程序,忽略选项 Use the 64 bit version of IIS Express for web sites and projects。而经典的 Web 应用程序将在 IIS Express 中运行,并具有您配置的特定位。对于您的方案,因为您使用的是单个分区集合并且错误很困惑。我假设您可以尝试创建一个经典的 Web 应用程序来隔离这个问题。
【解决方案2】:

我能够通过修改 web 项目 (*.csproj) 的标签 RuntimeIdentifier 使其在 VS 2017 中工作,如下图所示。

RuntimeIdentifier 已从 win7-x86 更改为 win7-x64。通过该更改加载了 IIS Express 64 位。

您无法从属性中更改 RuntimeIdentifier,您必须直接在文件中进行更改。

在这些更改之后,IIS Express 64 位开始运行,并且没有再次抛出错误。

*.csproj image

【讨论】:

    【解决方案3】:

    接受的答案对我不起作用。将其更改为 win10-x64 也没有帮助。

    帮助的是在 csproj 项目的标签下添加 false 。也可以通过 UI 通过单击项目属性 -> Web 选项卡 -> Bitness(更改为 x64)来使用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-04
      • 2016-05-24
      • 2017-09-03
      • 2016-11-13
      • 1970-01-01
      • 2019-04-22
      • 2012-08-15
      • 2019-05-13
      相关资源
      最近更新 更多