我将我的TeamCity更新到最新版本.(10.0 build 42002)
从那时起,构建代理无法构建我的任何项目.
代理人告诉我以下内容:
Unmet requirements: DotNetFramework4.0_x86 exists
Run Code Online (Sandbox Code Playgroud)
为了解决这个问题,我已经完成了这个stackoverflow问题中的建议: TeamCity Agent缺少DotNetFramework4.0_x86,但不是吗?
可悲的是,它不起作用.所以我查看了日志文件,但没有发现任何奇怪的东西.然后我查看了代理配置参数.我找到了这个:
DotNetFramework4.6.01055_x64_Path C:\Windows\Microsoft.NET\Framework64\v4.0.30319
DotNetFramework4.6.01055_x86_Path C:\Windows\Microsoft.NET\Framework\v4.0.30319
DotNetFramework4.6_x64 4.6.01055
DotNetFramework4.6_x64_Path C:\Windows\Microsoft.NET\Framework64\v4.0.30319
DotNetFramework4.6_x86 4.6.01055
DotNetFramework4.6_x86_Path C:\Windows\Microsoft.NET\Framework\v4.0.30319
Run Code Online (Sandbox Code Playgroud)
如您所见,.NET 4.0 Framework已映射到DotNetFramework4.6.对我来说,这似乎是个问题.
有人知道我可以做些什么来解决这个问题?
我搜索了很长时间来解决我的问题.我有一个自定义AuthorizeAttribute需要依赖于可以访问DbContext的"服务".遗憾的是,依赖注入在自定义AuthorizeAttribute中不起作用,并且始终为null.
我想出了一个(对我来说)可接受的解决方案.现在我想知道我的解决方案是否会导致不可预见的行为?
的Global.asax.cs
CustomAuthorizeAttribute.AuthorizeServiceFactory = () => unityContainer.Resolve<AuthorizeService>();
Run Code Online (Sandbox Code Playgroud)
CustomAuthorizeAttribute.cs
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
public class CustomAuthorizeAttribute : AuthorizeAttribute
{
public static Func<AuthorizeService> AuthorizeServiceFactory { get; set; }
public Privilege Privilege { get; set; }
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
bool authorized = base.AuthorizeCore(httpContext);
if (!authorized)
{
return false;
}
return AuthorizeServiceFactory().AuthorizeCore(httpContext, Privilege);
}
}
Run Code Online (Sandbox Code Playgroud)
AuthorizeService.cs
public class AuthorizeService
{
[Dependency]
public UserService UserService { private get; set; }
public bool AuthorizeCore(HttpContextBase httpContext, Privilege privilege) …Run Code Online (Sandbox Code Playgroud) c# entity-framework dependency-injection authorize-attribute asp.net-mvc-5
我有以下问题:我有一个看起来像这样的json文件
{
"Path": {
"FirstPath": "/1/2/text()"
}
}
Run Code Online (Sandbox Code Playgroud)
如果我像这样用Newtonsoft解析这个JSON-File
dynamic dyn = JObject.Parse(json);
Run Code Online (Sandbox Code Playgroud)
或这个
dynamic dyn = JsonConvert.DeserializeObject(json);
Run Code Online (Sandbox Code Playgroud)
我得到一个需要像这样使用的动态对象
dyn.Path.FirstPath.Value
Run Code Online (Sandbox Code Playgroud)
我怎样才能摆脱Value的东西?JSON中的所有对象最终都是一个字符串.如果没有必要,我不想总是在末尾写".Value".
我有一个简单的Angular 5应用程序,它带有一个HttpInterceptor,它在发出请求时通知服务。组件可以订阅此服务以获取此信息。
此处有错误的完整示例 => https://stackblitz.com/edit/angular-5b86se
在我的AppComponent 中,当我的子组件 ( HelloComponent ) 中发出请求时,我想显示一个加载指示器。
import { Component } from '@angular/core';
import { LoadingIndicatorService } from './loading-indicator.service';
@Component({
selector: 'my-app',
template: `<div *ngIf="loading" style="color:red">pretend this is loading indicator</div>
<hello name="{{ name }}"></hello>`
})
export class AppComponent {
name = 'Angular 5';
loading: boolean = false;
constructor(private loadingIndicatorService: LoadingIndicatorService) {
loadingIndicatorService
.onLoadingChanged
.subscribe(isLoading => this.loading = isLoading);
}
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
错误:ExpressionChangedAfterItHasBeenCheckedError:检查后表达式已更改。以前的值:'假'。当前值:“真”。
如果我是正确的,当子组件更改父组件中的值时会出现此错误。
但是我的子组件(HelloComponent)只执行 HttpGet 并且HttpInterceptor正在通过具有可观察的服务更改父组件( …
我试图实现一个名为“CryptographyConfigProvider”的自定义 JsonConfigurationProvider,如果它是加密的,它会从流中解密 JSON。
我从 JsonConfigurationProvider 继承并实现了自定义加载方法。
我在 Program.cs 中这样使用它:
var configuration = new ConfigurationBuilder()
.AddEncryptedJsonFile($"appsettings.{enviromentValue}.json", optional: true, reloadOnChange: false)
.Build();
Run Code Online (Sandbox Code Playgroud)
此调用执行我的自定义实现。(见下文)
但是在此 ASP.NET Core 尝试再次访问 appsettings 文件之后:
webHostBuilder.Build().Run();
Run Code Online (Sandbox Code Playgroud)
异常表明调用的是普通的 JsonConfigurationProvider 而不是我继承的类 CryptographyConfigProvider。
System.FormatException: Could not parse the JSON file. Error on line number '0': 'EncryptedString'.
---> Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: S. Path '', line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
at Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser.Parse(Stream input)
at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream)
--- End of inner exception stack trace …Run Code Online (Sandbox Code Playgroud) 我目前正在努力解决一个简单的 SQL 问题,我似乎无法使用“纯”Entity Framework Core 2.2 来解决这个问题。
如何在不执行以下操作的情况下检查插入期间实体是否已存在?
var entity = await _repository.Get(message.Id);
if(entity == null)
{
entity = new Entity ();
// do something with the entity
await _repository.AddAsync(entity);
}
else
{
// do something with the entity
await _repository.Update(entity);
}
await _repository.SaveChangesAsync();
Run Code Online (Sandbox Code Playgroud)
这还不够安全。我不断收到主键违规。我的服务在多个实例上运行,我在短时间内收到具有相同主键的消息。
是否有更好更安全的方法来检查实体是否已存在于 Entity Framework Core 中,而无需自己编写 SQL?
我想编写/编程/开发一种算法,可以识别来自/ mic音频线的数据中的许多特征.音频流将是音乐,我想过滤掉特征以区分彼此的歌曲,通过区分我的意思是你可以分别调用歌曲的类型.
我绝对想要发现的一件至关重要的事情是这首歌有什么样的酒吧/节拍.例如,我想知道这首歌是否处于3/4时间.
我发现的唯一有用的文章是关于BPM检测,但这还不足以将歌曲与另一首歌曲区分开来.
FFT是从音频流中获得不同特性的良好开端,但我不知道从哪里开始.是否可以通过FFT获得条形/节拍?有关于此的任何好的教程/代码示例吗?
FFT是否足以获得音频流的良好特性,或者是否有其他算法可以在音频流中获得特性?
我最好在C#中这样做,因为这是我最熟悉的编程语言.这可能是C#还是另一种语言更好?
总结我的问题,我正在寻找有关在音频流中查找特征的任何信息,以获得节拍/条和其他信息来区分歌曲.
我的 dotnet 核心项目有问题。我有一个 TFS 构建,它执行“dotnet 发布”并将应用程序部署到 IIS。
发布命令如下所示:
dotnet publish -o $(build.stagingDirectory) -c Release --self-contained --runtime win81-x64
Run Code Online (Sandbox Code Playgroud)
我的代码没有改变,但现在在 TFS 上运行构建时出现以下错误:
NETSDK1067: Self-contained applications are required to use the application host. Either set SelfContained to false or set UseAppHost to true.
Run Code Online (Sandbox Code Playgroud)
上周我们将构建服务器更新为最新的 .NET Core SDK,所以我想这可能与此有关。
发生了什么变化,我该怎么做才能使构建再次工作?
在我的 ASP.NET Core 应用程序中,我将 appsettings.json 绑定到强类型类AppSettings。
public Startup(IHostingEnvironment environment)
{
var builder = new ConfigurationBuilder()
.SetBasePath(environment.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{environment.EnvironmentName}.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public void ConfigureServices(IServiceCollection services)
{
services.Configure<AppSettings>(Configuration);
//...
}
Run Code Online (Sandbox Code Playgroud)
在单例类中,我像这样包装这个 AppSettings 类:
public class AppSettingsWrapper : IAppSettingsWrapper
{
private readonly IOptions<AppSettings> _options;
public AppSettingsAdapter(IOptions<AppSettings> options)
{
_options = options ?? throw new ArgumentNullException("Options cannot be null");
}
public SomeObject SomeConvenienceGetter()
{
//...
}
}
Run Code Online (Sandbox Code Playgroud)
现在,如果 json 文件发生更改,我正在努力重新加载 AppSettings。我在某处读到 …
c# asp.net-core-mvc asp.net-core asp.net-core-webapi asp.net-core-2.0
我在 Angular(版本 5.2.0)中为所有未处理的异常实现了一个全局错误处理程序。
全局错误处理程序如下所示:
import { Router } from '@angular/router';
import { ErrorHandler, Injectable, Injector, NgZone } from '@angular/core';
import { LoggingService } from '../services/logging.service';
@Injectable()
export class GlobalErrorHandler implements ErrorHandler {
private router: Router;
constructor(injector: Injector, private zone: NgZone, private loggingService: LoggingService) {
setTimeout(() => {
this.router = injector.get(Router);
});
}
handleError(error) {
this.loggingService.logErrorToApi(error);
this.zone.run(() => this.router.navigate(['/error']));
}
}
Run Code Online (Sandbox Code Playgroud)
仅当我有电话时,路由才有效this.zone.run(...)。如果我删除此调用,路由只会将路由添加error到 URL,并且不会显示组件。ngOnInit 也没有被调用。
如果我必须使用这样的“黑客”来让我的路由对我起作用,那么我的应用程序中的某个地方似乎配置错误。
有人知道我需要更改什么才能使其在没有区域呼叫的情况下运行吗?
我的路线:
const appRoutes: Routes = [
{
path: 'error',
component: ErrorComponent …Run Code Online (Sandbox Code Playgroud) 我不确定我是否没有得到大局,或者我是否只是错过了一些东西,但是将 JSON-String 解析为动态对象有什么好处?
如果我有一堂这样的课
class Product
{
public string Name { get; set; }
public double Price { get; set; }
public string Category { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我使用 HttpClient 来获取这样的对象
Product product = await response.Content.ReadAsAsync<Product>();
Run Code Online (Sandbox Code Playgroud)
我从这段代码中得到什么好处?
string content = await response.Content.ReadAsStringAsync();
dynamic product = JObject.Parse(content);
Run Code Online (Sandbox Code Playgroud)
如果我想使用它们,我需要写
product.Name
Run Code Online (Sandbox Code Playgroud)
使用强类型方法,我至少有智能感知。如果服务更改了产品,动态方法也无济于事,因为我仍然需要像上面提到的那样访问它。
那么我错过了什么?我为什么要使用动力学或何时使用?
我已按照https://update.angular.io的说明将Angular应用程序从5.2版升级到6.0版。
现在,由于“ rxjs-5-to-6-migrate”迁移,我的Angular应用程序无法构建:
bla.ts中的错误:错误TS2339:类型“可观察”上不存在属性“地图”。
我有以下进口:
import { Observable } from 'rxjs/observable';
import { of } from 'rxjs/observable/of';
import { map } from 'rxjs/operators';
Run Code Online (Sandbox Code Playgroud)
如果我这样更改导入,它将起作用:
import { Observable } from 'rxjs/observable';
import 'rxjs/Rx';
Run Code Online (Sandbox Code Playgroud)
但是我不明白为什么...我想使用显式导入而不是导入所有运算符。
更新:正如一些答案指出的那样,我必须使用管道才能使用运算符。这是我的问题,因为我认为我仍然可以将操作员链接到可观察对象。
老款式:
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
this.http.get('/api/appsettings/get').map(data => { return true; }).catch(() => { return Observable.of(false); });
Run Code Online (Sandbox Code Playgroud)
新风格
import { of, Observable } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
this.http.get('/api/appsettings/get').pipe(map(data => { return …Run Code Online (Sandbox Code Playgroud)