【发布时间】: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.DocumentQuery
1.<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