小编use*_*152的帖子

类型“Promise<void>”不可分配给类型“MouseEventHandler<HTMLButtonElement>”

我正在尝试构建一个 spfx web 部件,在同一上下文中更新列表,\n该按钮触发一个函数,该函数从上下文中获取当前用户名和日期,构建一个 json,然后将其字符串化,然后构建一个图形请求并将其与一个事件放在一起onclick

\n

我收到以下错误:

\n
\n

类型“Promise”不可分配给类型\n“MouseEventHandler”。类型 'Promise'\n 与签名 '(event:\nMouseEvent<HTMLButtonElement, MouseEvent>): void'.ts(2322)\nindex.d.ts(1449, 9): 预期类型来自属性 ' 不匹配onClick'\n这是在类型上声明的\n'DetailedHTMLProps<ButtonHTMLAttributes

\n
\n

签名WP.tsx:

\n
import * as React from 'react';\nimport * as strings from 'SignatureWpWebPartStrings';\nimport styles from './SignatureWp.module.scss';\nimport { ISignatureWpProps, ISignatureWpState, SharepointListItem} from './ISignatureWpProps';\nimport { escape } from '@microsoft/sp-lodash-subset';\nimport { Checkbox } from 'office-ui-fabric-react';\nimport { ServiceKey, ServiceScope } from "@microsoft/sp-core-library";\nimport { PageContext } from "@microsoft/sp-page-context";\nimport * as moment from 'moment';\nimport { WebPartContext } from "@microsoft/sp-webpart-base";\nimport { ClientMode } from …
Run Code Online (Sandbox Code Playgroud)

reactjs spfx microsoft-graph-api

7
推荐指数
1
解决办法
1万
查看次数

在FontFamilyCollection中找不到FontFamily元素

我的WPF应用程序突然失败,出现以下异常:

System.IO.FileFormatException:在FontFamilyCollection中找不到与当前操作系统或更高版本匹配的FontFamily元素:Windows7SP1

我尝试过不同的操作系统,但它只发生在带有SP1的Windows 7上.

wpf

6
推荐指数
2
解决办法
6256
查看次数

Microsoft ToDo 任务创建订阅图形 API 中出现禁止错误

使用 Graph API 创建订阅时,即使我们在访问令牌中有足够的权限,也会收到以下错误。

令牌权限:Calendars.ReadWrite Contacts.ReadWrite Tasks.ReadWrite User.Read profile openid email

{
  "error": {
    "code": "ExtensionError",
    "message": "Operation: Create; Exception: [Status Code: Forbidden; Reason: Access is denied to the requested resource. The user might not have enough permission.]",
    "innerError": {
        "date": "2022-11-30T08:23:03",
        "request-id": "0541655d-83f3-456e-af47-165caf259c76",
        "client-request-id": "0541655d-83f3-456e-af47-165caf259c76"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

使用的详细信息:

请求网址:

POST https://graph.microsoft.com/v1.0/subscriptions 
Run Code Online (Sandbox Code Playgroud)

请求正文:

{
    "notificationUrl":"<development-url>/notifications/office365/graph/v1",
    "expirationDateTime":"2022-12-03T06:48:06Z",
    "resource":"/me/todo/lists/{taskListId}/tasks",
    "changeType":"created,updated,deleted",
    "clientState":"<client-state>"
}
Run Code Online (Sandbox Code Playgroud)

使用的 API - https://graph.microsoft.com/v1.0/subscriptions微软文档

问题影响的用户数 - 190

azure microsoft-graph-sdks microsoft-todo microsoft-graph-api

5
推荐指数
1
解决办法
162
查看次数

使用 log4net 写入两个不同的文件

我想在我的应用程序中使用两个不同的记录器,这样我就能够将不同的消息记录到不同的文件中。我的 app.config 看起来像

<log4net>
<appender name="Appender1" type="log4net.Appender.RollingFileAppender">
  <file value="File1" />
  <appendToFile value="true" />
  <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
  <maxSizeRollBackups value="10" />
  <maximumFileSize value="1MB" />
  <rollingStyle value="Composite" />
  <staticLogFileName value="false" />
  <datePattern value=".yyyy-MM-dd'.txt'" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread] %-5level %logger - %message %exception{Message} %newline" />
    <IgnoresException value="False" />
  </layout>
</appender>
<appender name="Appender2" type="log4net.Appender.RollingFileAppender">
  <file value="File2.Log"/>
  <appendToFile value="true" />
  <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
  <maxSizeRollBackups value="100" />
  <maximumFileSize value="10MB" />
  <rollingStyle value="Size" />
  <staticLogFileName value="true" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date %message %newline" />
    <IgnoresException value="True" …
Run Code Online (Sandbox Code Playgroud)

c# log4net

4
推荐指数
1
解决办法
3939
查看次数

Prism ServiceLocator GetInstance和MEF

我正在尝试使用Microsoft.Practices.ServiceLocation.ServiceLocator和MEF.接口IServiceLocator使用两个参数定义方法GetInstance.第一个参数是serviceType,第二个参数是关键.

我有两个实现接口IMyInterface的类,它们具有Export属性:

[Export(typeof(IMyInterface)), PartCreationPolicy(CreationPolicy.Shared)]
public class Class1 : IMyInterface 
{}

[Export(typeof(IMyInterface)), PartCreationPolicy(CreationPolicy.Shared)]
public class Class2: IMyInterface 
{}
Run Code Online (Sandbox Code Playgroud)

我想通过Prism ServiceLocator GetInstance方法获取Class1的实例:

ServiceLocator.Current.GetInstance(typeof(IMyInterface),"Key");
Run Code Online (Sandbox Code Playgroud)

但我不知道应该如何定义"关键".我试图在export属性中定义键:

[Export("Key1",typeof(IMyInterface)), PartCreationPolicy(CreationPolicy.Shared)]
public class Class1 : IMyInterface 
{}

[Export("Key2",typeof(IMyInterface)), PartCreationPolicy(CreationPolicy.Shared)]
public class Class2: IMyInterface 
{}
Run Code Online (Sandbox Code Playgroud)

当我用关键参数调用方法GetInstance时

ServiceLocator.Current.GetInstance(typeof(IMyInterface),"Key1");
Run Code Online (Sandbox Code Playgroud)

我得到Microsoft.Practices.ServiceLocation.ActivationException(尝试获取IMyInterface类型的实例,键"Key1"时发生激活错误).有人知道如何定义导出键吗?谢谢

c# prism mef

3
推荐指数
1
解决办法
6760
查看次数

PostgreSql - 声明整型变量

我试图在 postgresql sql 脚本中声明默认值 0 的整数变量:

DECLARE user_id integer;
Run Code Online (Sandbox Code Playgroud)

但它返回异常:

错误:“整数”处或附近的语法错误

我不确定如何声明一个变量,然后在 while 循环内使用该变量。

postgresql

3
推荐指数
2
解决办法
2万
查看次数

以编程方式将证书添加到受信任的发布者

我有一个已签名的 USB 驱动程序。我也有出版商提供的证书。如果我尝试安装驱动程序pnputil

pnputil /add-driver CerttName.cer /install
Run Code Online (Sandbox Code Playgroud)

系统询问我是否要将发布者添加到受信任的发布者。

为了避免它,我尝试以编程方式将证书添加到 Trusted Publishers

string file = @"C:\Certificates\CertName.cer";
X509Store store = new X509Store(StoreName.TrustedPublisher, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadWrite);
store.Add(new X509Certificate2(X509Certificate2.CreateFromCertFile(file)));
store.Close();
Run Code Online (Sandbox Code Playgroud)

证书已添加,但仍提示我pnputil将发布者添加到受信任的发布者。

如果我使用 certutil

certutil -addstore "TrustedPublisher" CertName.cer
Run Code Online (Sandbox Code Playgroud)

那么我不会被提示pnputil

我还尝试从 certmgr.msc 手动导入证书,但它也不起作用。

我不明白为什么只certutil工作而其他方式(特别是 X509Store)不行。

c# x509certificate2 certutil

2
推荐指数
1
解决办法
837
查看次数