Visual Studio 2017(15.x)支持C#7,但Visual Studio 2015(14.x)呢?
我怎样才能使用C#7?
我创建了一个ASP.NET-WebApi应用程序,我遇到了这个错误:
HttpConfiguration不包含SuppressDefaultHostAuthentication的定义
代码是自动生成的,我认为它必须是一个引用,但无法找到该引用.
using System.Web.Http;
using Microsoft.Owin.Security.OAuth;
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Configure Web API to use only bearer token authentication.
config.SuppressDefaultHostAuthentication();
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Spring Tool Suite进行Spring MVC项目.我找不到在发布模式下导出我的战争的选项.Eclipse在导出战争时是否默认执行此操作?
也许Eclipse默认使用Debug模式,但是在导出war时会自动更改模式.
我知道发布版本已经过优化,这就是为什么我想了解如何在该版本中导出我的战争.
我在VisualStudio中创建了一个asp.net mvc项目,并将其发布在Github中。我注意到默认情况下该文件被忽略。ApplicationInsights.config
现在,由于缺少此文件,因此无法在克隆时编译项目。之后,我将其手动添加到存储库中,一切按预期进行。
为什么默认情况下会忽略此文件?将此文件添加到存储库是不好的做法吗?
我正在尝试使用NLog记录内部异常消息.这是我的NLog.config文件的一部分:
<target name="errors" xsi:type="File" layout="${longdate}${newline}
- Exception Message: ${exception:format=Message}${newline}
- InnerException Message: ${exception:innerExceptionSeparator=TEXT}${newline}"
fileName="\Logs\errors-${shortdate}.log"
concurrentWrites="true" />
</targets>
Run Code Online (Sandbox Code Playgroud)
我正在为NLog.config文件和See the inner exception for details
两行获取相同的消息.Exception Message
InnerException Message
当我尝试将 Asp.Net MVC 项目发布到网络托管时,I\xc2\xb4m 收到此错误:
\n\n\n\n\n诊断日志已写入以下位置:C:\\Users\\MyUser\\AppData\\Local\\Temp...
\n
I\xc2\xb4m 使用 Visual Studio 2017,为了发布该项目,我从托管下载了 PublishSettings。
\n\n.Net版本是4.6.1。
\n\n日志显示发布由于构建错误而失败,但在编译解决方案时没有看到构建错误。这是日志:
\n\n\n\n2018 年 6 月 5 日上午 11:39:20 System.AggregateException: 发生一个或多个错误。---> System.Exception: 由于生成错误,发布失败。\n 检查错误列表以获取更多详细信息。--- 内部异常结束\n 堆栈跟踪 --- at\n System.Threading.Tasks.Task.ThrowIfExceptional(Boolean\n includeTaskCanceledExceptions) at\n System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout,\n CancellationToken CancellationToken) 位于\n Microsoft.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish.<>c__DisplayClass40_0.b__2()\n 位于 System.Threading.Tasks.Task`1.InnerInvoke() 位于\n System.Threading.Tasks。 Task.Execute()\n --- 从先前引发异常的位置开始的堆栈跟踪结束 --- at\n System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task\n task) at\n System.Runtime.CompilerServices .TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task\n task) at\n Microsoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.d__108.MoveNext()\n ---> (内部异常 #0) System.Exception: 由于以下原因发布失败构建错误。检查错误列表以获取更多详细信息。<---
\n\n===================
\n
我正在使用 HQL 查询,其中包含类似于...
INSERT OVERWRITE TABLE ex_tb.ex_orc_tb
select *, SUBSTR(INPUT__FILE__NAME,60,4), CONCAT_WS('-', SUBSTR(INPUT__FILE__NAME,71,4), SUBSTR(INPUT__FILE__NAME,75,2), SUBSTR(INPUT__FILE__NAME,77,2))
from ex_db.ex_ext_tb
Run Code Online (Sandbox Code Playgroud)
当我进入 hive 并使用该命令时,它工作正常。
当我把它放入一个 pyspark, hivecontext 命令时,我得到了错误......
pyspark.sql.utils.AnalysisException: u"cannot resolve 'INPUT__FILE__NAME' given input columns: [list_name, name, day, link_params, id, template]; line 2 pos 17"
Run Code Online (Sandbox Code Playgroud)
任何想法为什么会这样?
根据MSDN,类的Resolve<T>()
方法UnityContainer
使用如下:
var controller = container.Resolve<ManagementController>();
Run Code Online (Sandbox Code Playgroud)
但是,我在UnityContainer
类定义中找不到该方法.我只能看到:
public class UnityContainer : IUnityContainer, IDisposable
{
// Other methods
public object Resolve(Type t, string name, params ResolverOverride[] resolverOverrides);
public IEnumerable<object> ResolveAll(Type t, params ResolverOverride[] resolverOverrides);
// Other methods
}
Run Code Online (Sandbox Code Playgroud)
我使用了错误的包裹还是什么?
这些是我安装的包.
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;
Run Code Online (Sandbox Code Playgroud) SELECT `apps`.*,
COUNT(all_users.id) AS total_users,
COUNT(active_users.id) AS active_users
FROM `apps`
INNER JOIN `social_users` AS `all_users` ON `all_users`.`app_id` = `apps`.`id`
INNER JOIN `social_users` AS `active_users` ON `active_users`.`app_id` = `apps`.`id`
WHERE `active_users`.`is_active` = 'true'
GROUP BY `id`
ORDER BY `total_users` ASC LIMIT 30
OFFSET 0
Run Code Online (Sandbox Code Playgroud)
我有2张桌子.
apps -> id, name
social_user -> id, app_id, is_active
我想在apps表上运行查询并显示所有用户和所有活动用户.
我两次加入社交用户.
问题是,如果我加入它一次(无论哪个)它运行得非常快.第二次连接会导致性能下降并且数字根本不准确,我得到180000个用户而不是750个用户.
我怎样才能做得更好更快?
谢谢
我创建了一个ASP.NET-WebApi应用程序,我遇到了这个错误:
找不到类型或命名空间名称HostAuthenticationFilter ...
代码是自动生成的,我认为它必须是一个引用,但无法找到该引用.
using System.Web.Http;
using Microsoft.Owin.Security.OAuth;
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Configure Web API to use only bearer token authentication.
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
Run Code Online (Sandbox Code Playgroud) 我需要知道哪种方法更快.
// Approach1
var filteredList = MyList.Where(x => x.IsNull);
foreach (var item in filteredList)
{
// Do someghing...
}
// Approach2
foreach (var item in MyList.Where(x => x.IsNull))
{
// Do someghing...
}
Run Code Online (Sandbox Code Playgroud)
Where
每次foreach
迭代时最后一个都执行吗?
c# ×5
.net ×3
asp.net-mvc ×2
apache-spark ×1
c#-7.0 ×1
database ×1
eclipse ×1
git ×1
git-clone ×1
github ×1
hivecontext ×1
hql ×1
java ×1
logging ×1
mysql ×1
nlog ×1
publishing ×1
pyspark ×1
release ×1
spring-mvc ×1
sql ×1
war ×1
web-hosting ×1