我有两个项目:一个是MVC4应用程序,另一个是输出类型类库.
我想让第二个项目(类库一个)成为洞察力的沟通层.
代码编译,服务器正常运行.
public static void SaveMetric(string title, double value,
string azureKey, Dictionary<string, string> properties = null)
{
try
{
TelemetryClient telemetry = new TelemetryClient();
telemetry.InstrumentationKey = azureKey;
telemetry.TrackMetric(title, value, properties);
}
catch (Exception ex)
{
var a = "";
}
}
Run Code Online (Sandbox Code Playgroud)
当我调用该telemetry.TrackMetric函数时,问题就出现了.此代码返回错误:
"对象引用未设置为对象的实例."(System.NullReferenceException).
是否可以在类库项目中使用Microsoft Insights?如果是的话,我做错了什么?
我正在建立一个非常复杂的管道来处理遗留构建。目前有 8 个阶段,还有更多的阶段 - 可能总共有 12-15 个阶段。
每个阶段执行非常相似的操作: - 获取一个列表,并为每个项目 - 在映射中创建条目 - 分配一个节点,并执行一组 BAT 脚本(是的,窗口),然后并行运行列表
当前管道长约 1,000 行,我收到“方法太大”错误
我正在将此 DSL 重构为单独的可加载脚本。
到现在为止还挺好。
但我刚刚运行了一个测试,表明加载脚本是对整个管道的补充。所以我想了解在这里做什么是最好的。
测试:
base.groovy:
def myVar //wchi is global (to basRef, i thought)
def setTest() { myVar='abc' }
def getTest() { return myVar }
Run Code Online (Sandbox Code Playgroud)
管道.groovy
stage('one') {
def basRef = load('base.groovy')
basRef.setTest()
echo basRef.getTest()
}
stage('two') {
def basRef = load('base.groovy')
echo basRef.getTest()
}
Run Code Online (Sandbox Code Playgroud)
第一阶段按预期显示“abc”。第二阶段也显示“abc”
我的问题:
我怎么知道使用loadable文件不会导致“方法太大”?
可加载文件的范围是什么?
我试过设置basRef = null允许垃圾收集工作,但我不确定它是否确实如此。
感谢您对此的任何指导。
我有一个asp.net mvc应用程序,我发生了这个奇怪的事情,我不知道为什么.
语境:
我有一个页面,允许用户绘制和编辑图像.这个页面有一个功能,每5分钟,她使用jquery对服务器进行ajax调用,在数据库上保存项目的当前状态,另一个调用保存存储在适当位置的项目的图像.
问题:
通过最小化浏览器,启动此功能后,在ajax调用服务器后,将删除cookie Customer .但是当镀铬最大化时,这样可以正常工作.
笔记:
我知道你很难仅仅提供这些信息,但是,如果你能给我提供线索,那将是非常有帮助的.我正在尝试揭露问题,以便我们可以匹配类似的问题,以找到针对此案例的最佳解决方案.
先感谢您
[编辑]:
我对这个问题有一些新的看法:

按照jquery通话代码:
makeAjaxCall(ajaxData) {
var localData = ajaxData.data ? ajaxData.data : {},
urlVariables = {};
localData.cmd = ajaxData.cmd;
var controlerURL = ajaxData.uploadUrl ? HelperJSViewBag.getValue("ajaxCAllUploadURL") : ajaxData.controller;
if (typeof ajaxData.data.urlVariables == "undefined")
ajaxData.data.urlVariables = [];
let editorVersion = "";
let forceEditorVersion = "";
if (typeof UrlParameters != "undefined") {
editorVersion …Run Code Online (Sandbox Code Playgroud)我使用茉莉花作为测试框架,使用业力作为测试运行程序。我正在尝试创建HttpClient对象,因此我可以创建一个服务作为对此对象的依赖:
TestBed.configureTestingModule({
declarations: [HttpClient],
imports: [HttpClient],
providers: [HttpClient]
});
TestBed.get(HttpClient);
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
错误:模块'DynamicTestModule'导入了意外的值'HttpClient'。请添加一个@NgModule批注。
有人知道如何解决这个问题吗?
遵循所有代码:
import { I18nService } from "../../services/i18n.service";
import { TestBed, inject, async } from "@angular/core/testing";
import { EditionHistoryEventsModel } from "./dropdown.edition.history.events.model";
import { HttpClient } from "@angular/common/http";
import { TestUtil } from "../../utils/test.uti";
describe('DropDownEditionHistoryItemModel', () => {
let i18nService: I18nService;
beforeAll(() => {
TestBed.configureTestingModule({
declarations: [HttpClient],
imports: [HttpClient],
providers: [HttpClient]
});
i18nService = TestUtil.geti18nService(TestBed.get(HttpClient));
});
it('asdasd', () => {
let model: EditionHistoryEventsModel = new EditionHistoryEventsModel(i18nService);
expect(true).toBeTruthy();
}); …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
export class EventsChainComponent {
eventSubscriber:Subscription;
constructor (protected eventService: EventService) {}
public registerComponentsEvent(event:any) {
// getOnEvent signature
// (method) EventService.getOnEvent(): Observable<FormEvent>
this.eventSubscriber = this.eventService.getOnEvent()
.pipe(filter((formEvent: FormEvent) => {return formEvent.key == event.event}))
.subscribe((formEvent: FormEvent) => {
..........
});
}
Run Code Online (Sandbox Code Playgroud)
当我编译时,编译器返回以下错误:
“MonoTypeOperatorFunction”类型的参数不可分配给“OperatorFunction”类型的参数。
所以,我搜索了一下,发现了RxJs6操作符过滤器 API:
export declare function filter<T, S extends T>(predicate: (value: T, index: number) => value is S, thisArg?: any): OperatorFunction<T, S>;
export declare function filter<T>(predicate: (value: T, index: number) => boolean, thisArg?: any): MonoTypeOperatorFunction<T>;
Run Code Online (Sandbox Code Playgroud)
如您所见,过滤器作为 2 个重载方法,一个返回OperatorFunction …
我有一个反应应用程序,每次部署新版本时,一些用户由于浏览器缓存而无法获得新版本。
任何人都可以告诉我如何在每次部署新版本的软件时清理浏览器缓存?
我有以下代码:
import { Injectable } from "@angular/core";
@Injectable()
export abstract class ClientCacheService {
private subscriptionId: string;
protected getId(key :string, prefix:string=""): string {
return `${this.subscriptionId}_${prefix}_${key}`;
}
constructor(subscriptionId: string) {
this.subscriptionId = subscriptionId;
}
abstract setCache(key :string, prefix:string, object: any): void;
abstract getCache(key :string, prefix:string): void;
abstract removeCache(key :string, prefix:string): any;
}
import { ClientCacheService } from "./client-cache.service";
import { Injectable } from "@angular/core";
@Injectable()
export class SessionCacheService extends ClientCacheService {
constructor() {
super("TEST");
}
setCache(key: string, prefix: string, object: any): void …Run Code Online (Sandbox Code Playgroud) 我试图扩展基类并得到以下错误:
类'DerivedProduct'错误地扩展了基类'BaseProduct'.
类型具有私有属性"路由"的单独声明.
基类:
export class BaseProduct {
constructor(private route: ActivatedRoute, private store: Store<fromState>){}
}
Run Code Online (Sandbox Code Playgroud)
派生类:
export class DerivedProduct extends BaseProduct {
constructor(private route: ActivatedRoute, private store: Store<fromState>){}
}
Run Code Online (Sandbox Code Playgroud)
为什么我收到此错误?
我正在从角度5迁移到角度6。当我使npm run build时,我将其抛出以下错误:
ngc编译失败:ng-formly / core / src / components / formly.field.ts(10,10):错误TS2305:模块'“ C:/PrjNET/Elevation3/FW/4.00/Mainline/Framework/Development/Client/ ElevationJS / ngcore / .tmp / node_modules / rxjs / Subscription“'没有导出的成员'Subscription'。
我有一个类似的错误:rxjs/Subscription has no exported member Subscription我可以通过导入Subscription来解决:
import { Subscription } from "rxjs";
Run Code Online (Sandbox Code Playgroud)
但是我不能这样做ISubscription。
谁知道如何导入ISubscription?
angular ×5
typescript ×4
ajax ×1
android ×1
asp.net ×1
c# ×1
cookies ×1
frontend ×1
google-dfp ×1
jasmine ×1
javascript ×1
jquery ×1
reactjs ×1
rxjs ×1
rxjs6 ×1
scrollbar ×1
unit-testing ×1