按照以下菜单顺序:
文件 - >新建 - >项目 - > ASP> .NET核心Web应用程序(.Net Framework)
构建 - >构建解决方案
得到此错误:
错误C:\ Users\Sam\Documents\Visual Studio 2015\Projects\RC2 Test\src\RC2 Test\error CS2001:源文件'C:\ Users\Sam\Documents\Visual Studio 2015\Projects\RC2 Test\src \找不到RC2 Test\Test.deps.json'.RC2测试C:\ Program Files(x86)\ MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets 241
搜索test.deps什么也找不到.
"test"是单元测试项目的硬编码名称吗?
dotnet --version说1.0.0.0-preview1-002702
编辑:
我重复了上述步骤,但这次我选择了Core Web Application(.Net Core).我犯了同样的错误.
看起来我们不能在项目名称中使用空格.
此代码抛出异常.是否可以定义将捕获它的应用程序全局处理程序?
string x = await DoSomethingAsync();
Run Code Online (Sandbox Code Playgroud)
使用.net 4.5/WPF
从.net RC2升级到RTM后,我发现需要为从ArrayPool派生的JsonOutputFormatter的构造函数提供参数.我如何获得这个对象?我正在手动创建JsonOutputFormatter,因为我需要配置ReferenceLoopHandling.
我能找到的其他相关信息是这样的:https: //github.com/aspnet/Mvc/issues/4562
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMemoryCache();
services.AddSession();
services.AddMvc();
var formatterSettings = JsonSerializerSettingsProvider.CreateSerializerSettings();
formatterSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
JsonOutputFormatter formatter = new JsonOutputFormatter(formatterSettings, ???);
services.Configure<MvcOptions>(options =>
{
options.OutputFormatters.RemoveType<JsonOutputFormatter>();
options.OutputFormatters.Insert(0, formatter);
});
//etc...
}
Run Code Online (Sandbox Code Playgroud) 错误消息:附加类型的实体失败,因为同一类型的另一个实体已具有相同的主键值.
问题:如何以类似的方式附加实体,如下面的代码中的AttachActivity方法所示?
我必须假设上面的错误消息的"另一个实体"部分是指存在于内存但超出范围(??)的对象.我注意到这一点,因为我尝试附加的实体类型的DBSet的Local属性返回零.
我有理由相信实体在上下文中不存在,因为我逐步完成代码并在创建时观察上下文.在创建dbcontext之后,实体将立即添加到几行中.
我正在测试这里指定的附加实体:找出实体是否附加到dbContext的最合理方法是什么?
当在visual studio的locals窗口中查看本地时,我看到没有类型为Activity的实体(无论ID),除了我想要附加的实体.
代码按以下顺序执行:Try - > ModifyProject - > AttachActivity
代码在注释行的AttachActivity中失败.
请注意调试注释之间的代码,如果已将任何实体添加到上下文中,则将抛出该代码.
private string AttachActivity(Activity activity)
{
string errorMsg = ValidateActivity(activity); // has no code yet. No. It does not query db.
if(String.IsNullOrEmpty(errorMsg))
{
// debug
var state = db.Entry(activity).State; // Detached
int activityCount = db.Activities.Local.Count;
int projectCount = db.Activities.Local.Count;
if (activityCount > 0 || projectCount > 0)
throw new Exception("objects exist in dbcontext");
// end debug
if (activity.ID == 0)
db.Activities.Add(activity);
else
{
db.Activities.Attach(activity); …Run Code Online (Sandbox Code Playgroud) 我正在运行Windows 8 IIS 8.5.
我在IIS上创建了我的网站,并在下面的目录中为我的webapi服务创建了另一个网站所以我的网站看起来像这样:
www.mysite.com
www.mysite.com/api //这在磁盘上存在于站点dir下面名为api的目录中.在IIS中配置为站点而非虚拟目录.
当然,iis无法为这两个站点实现路由.
如果我添加/index.html,ww.mysite.com有效.如果我在浏览器中输入www.mysite.com,我会收到404.
无论我做什么,api网站都会给我404错误.
在visual studio中运行时,这两个站点都可以正常工作 www.mysite.com是一个mvc 5应用程序www.mysite.com/api是一个webapi 3应用程序.
一些问题,如这一个:
ASP.NET 4.5 MVC 4不适用于Windows Server 2008 IIS 7
推荐
<modules runAllManagedModulesForAllRequests="true" />
Run Code Online (Sandbox Code Playgroud)
哪个不起作用,即使它确实有效也不是最理想的.
其他人发现的其他问题:
正在部署Global.asax.
.net 4.5安装在控制面板下 - >添加Windows功能 - > IIS - >应用程序开发
未安装WebDav
aspnet_regiis -i不相关(使用控制面板)
启用默认错误处理
这是web.configs:
web.config from mysite
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301880
-->
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings> …Run Code Online (Sandbox Code Playgroud) 我想我已经连接了基本的动画部分,我只需要知道要处理的事件.理想情况下,我想要一个我可以在导航级别使用的解决方案,所以我可以包装我的所有组件,但一个简单的页面加载示例就足够了,非常感激.我在SO上发现了其他一些相关问题,但它们似乎没有回答我的具体问题或过时:
使用Angular 2.0路由器和组件接口承诺的路由组件页面过渡动画的Angular 2"动画幻灯片"
这是我到目前为止:
html文件
<article @heroState="componentState">
<p>article element should fade in/out</p>
</article>
Run Code Online (Sandbox Code Playgroud)
零件
@Component({
selector: 'blog-about',
templateUrl: './app/about/about.html',
animations: [
trigger('heroState', [
state('active', style({
backgroundColor: 'blue',
transform: 'scale(1)'
})),
state('inactive', style({
backgroundColor: 'green',
transform: 'scale(1.1)'
})),
transition('active => inactive', animate('1000ms ease-in')),
transition('inactive => active', animate('1000ms ease-out'))
])
]
})
export class About implements OnInit, OnDestroy {
public componentState: string;
public Title: string
constructor() {
this.Title = "this is about";
}
ngOnInit()
{
this.componentState = 'inactive'; …Run Code Online (Sandbox Code Playgroud) 我有一个小实用工具方法,用于在using语句中实例化我的datacontext.我想在异步方法调用中使用它,但是在方法返回之前处理datacontext.使用它的正确方法是什么?
这是方法(和重载)
public void Try(Action<IDataServices> method)
{
using (IDataServices client = GetClient())
{
method(client);
}
}
public TResult Try<TResult>(Func<IDataServices, TResult> method)
{
using (IDataServices client = GetClient())
{
return (TResult)method(client);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我当前使用它的方式(失败):
Model m = await ClientResolver.Try(async x => await x.GetModelByIDAsync(modelID));
Run Code Online (Sandbox Code Playgroud)
参考:
在using语句中调用异步方法
在WriteTo.Observer方法中,我想传递格式化日志消息,因为它是使用格式化模板呈现的。我该怎么做?谢谢
class Program
{
static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo.LiterateConsole()
.WriteTo.RollingFile("log-{Date}.txt")
.WriteTo.Observers(events => events.Do(evt => { Console.WriteLine($"Observed event {evt.MessageTemplate.Text}"); }).Subscribe())
.WriteTo.Observers(events => events.Do(evt => { LogHandler(evt.MessageTemplate.Text);}).Subscribe())
.CreateLogger();
Log.Logger.Information("Log msg from Main");
Console.ReadLine();
}
public static void LogHandler(string logMsg)
{
Console.WriteLine("LogHandler: " + logMsg); //I want the complete formatted log message as it would appear in a file i.e. "[10:20:14 INF] Log msg from DoNothing"
}
}
Run Code Online (Sandbox Code Playgroud) c# ×4
.net ×3
async-await ×2
.net-core ×1
angular ×1
asp.net ×1
asp.net-core ×1
asp.net-mvc ×1
exception ×1
iis ×1
json.net ×1
routing ×1
serilog ×1