Visual studio2015和2017不启动IIS Express 64位版本

Visual studio 2015 and 2017 do not start IIS Express 64 bit version

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

此问题发生在 visual studio 2015(企业版 14.0.25431.01 更新 3)和 2017 RC(专业版 public.d15rel/15.0.26014.0)

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

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

附加信息:

System.AggregateException: One or more errors occurred. ---> 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.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.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.<CreateDocumentQueryExecutionContextAsync>d__12.MoveNext() --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result() at Microsoft.Azure.Documents.Linq.DocumentQuery1.d__b.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at 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()<---

"An attempt was made to load a program with an incorrect format.
(Exception from 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

System.NotSupportedException: Partition routing information cannot be extracted from the query when running in a 32-bit process.

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

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

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

您不能从属性中更改 RuntimeIdentifier,您必须直接在文件中更改它。

经过这些更改后,IIS Express 64 位启动了 运行 并且没有再次抛出错误。

*.csproj image

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

有用的是在csproj项目的标签下添加false。也可以通过 UI 单击项目属性 -> Web 选项卡 -> 位数(更改为 x64)。