我目前正在尝试迭代我的所有项目(sharepoint)以将所有功能guid放入文件中.我想在它们前面加上项目名称.我的问题是DTE.Solution.Item和DTE.Solution.Projects.Item(或foreach的枚举器)不会将整数作为参数,foreach返回一个不能转换为Project的对象.
这是我的代码片段:
var hostServiceProvider = (IServiceProvider) Host;
var dte = (DTE) hostServiceProvider.GetService(typeof(DTE));
var projectCount = dte.Solution.Projects.Count;
var projects = new Dictionary<string, string>();
foreach(Project dteProject in dte.Solution)
{
var dteProject = dte.Solution.Item(i);
projects.Add(dteProject.Name, dteProject.FullName);
}
Run Code Online (Sandbox Code Playgroud)
好的 - 代码没问题 - 调试器不是!抛出调试上下文的我的异常,但如果没有附加调试器,模板将运行正常.
在将ASPNetCore 1.1项目迁移到ASPNetCore 2.0的过程中,我们偶然发现Cookie-AuthN及其问题SessionStore。
ASP.NET Core 1允许我们执行以下操作:
public void ConfigureServices(...) {
Services.AddDistributedSqlServerCache(...);
Services.AddSingleton<DistributedCookieSessionStore>(); /// SQL based store
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory) {
var cookieOptions = app.ApplicationServices.GetRequiredService<IOptions<CookieAuthenticationOptions>>().Value;
cookieOptions.SessionStore = app.ApplicationServices.GetRequiredService<DistributedCookieSessionStore>();
app.UseCookieAuthentication(cookieOptions);
}
Run Code Online (Sandbox Code Playgroud)
凌乱,但尽其所能。
现在,使用ASP.NET Core 2时 app.UseAuthentication(),没有签名可以修改选项,并且我无法使用DI来保留会话存储。
我在服务器上运行WCF服务,该服务器配置为接受Kerberos身份验证.
Kerberos工作正常,因此WCF服务知道哪个用户连接到他.该服务提供一切作为异步方法.就像这里一样(只是一个清晰的例子).
public ExampleService : IExampleService {
public Task<string> GetUsernameAsync() {
return await Task.Run(() => System.Threading.Thread.CurrentPrincipal.Name);
}
}
Run Code Online (Sandbox Code Playgroud)
在客户端,我有一个Controller(它是一个MVC页面,但这没关系),它调用方法异步.
public ExampleController {
public async Task<ActionResult> Index() {
using(var serviceClient = ServiceFactory.GetServiceClient())
using(Security.Impersonation.Impersonate())
{
var data = await serviceClient.GetUsernameAsync();
return View(data);
}
}
}
Run Code Online (Sandbox Code Playgroud)
只要我不使用等待,模仿就可以正常工作.
由于Task<>没有流出模拟身份,我想知道是否有可能更改执行用户Task或执行任何其他操作以使模拟在此用例中起作用.
我尝试了一个自定义awaiter(因为它可以在那个案例中使用Culture),但这根本不起作用(好吧它也不会冒充).
我们尝试使用 Blazor KeaboardEventArgs 做一些事情,但在键名上遇到了困难。文档告诉我们:
事件所代表的键的键值。如果该值具有打印表示形式,则该属性的值与 char 属性相同。否则,它是“键值”中指定的键值字符串之一。如果无法识别密钥,则为字符串“Unidentified”
但“关键值”没有进一步指定。任何人都可以指出KeyboardEventArgs.Key和的可能值的(详尽)列表吗KeyboardEventArgs.Code?
我正在尝试创建一个dotnet new包含我的团队使用的“默认”.editorconfig 和 .gitconfig 的简单模板。
不幸的是,.files 不会被包含在dotnet pack.
这是我的 .csproj 的一部分:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageType>Template</PackageType>
<TargetFramework>net6.0</TargetFramework>
<IncludeContentInPack>true</IncludeContentInPack>
<IncludeBuildOutput>false</IncludeBuildOutput>
<ContentTargetFolders>content</ContentTargetFolders>
</PropertyGroup>
<PropertyGroup>
<Description>dotnet new templates</Description>
<PackageTags>template dotnet console</PackageTags>
<Version>1.0.0</Version>
</PropertyGroup>
<ItemGroup>
<Compile Remove="**\*" />
<Content Include="templates\**\*" Exclude="templates\**\bin\**;templates\**\obj\**;templates\**\.vs\**" />
<Content Include="templates\SolutionTemplate\.editorconfig;templates\SolutionTemplate\.gitignore" Pack="true" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
尽管已明确添加,但 .editorconfig 和 .gitignore 将被忽略。有人有这方面的经验吗?