小编Vel*_*dge的帖子

迁移到 .NET 6.0 发布时出现错误:资产文件没有“net5.0”的目标

我正在尝试从 .NET 5 迁移到 .NET 6。我已经安装了 VS 2022 Community Preview 和 Hosting Bundle...并更新了 NuGet 中的所有内容。该项目将正常构建,但当我发布它时,出现以下错误:

Assets file 'D:\Data\CADE.core\FileManager\FileManager\obj\project.assets.json' doesn't have a target for 'net5.0'. 
Ensure that restore has run and that you have included 'net5.0' in the TargetFrameworks for your project.
Run Code Online (Sandbox Code Playgroud)

我不知道为什么它仍在寻找 .NET 5 也不知道如何修复此错误。

c# .net-6.0 visual-studio-2022

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

如何从 VS 2022 创建的 gRPC 服务器创建 Windows 服务?

我通过选择“ASP NET Core gRPC Service”模板和.Net 6 Core,在 Visual Studio 2022 Community Preview 中创建了一个 gRPC 服务器。我打算替换四个现有的.Net Framework Windows 服务,它们都使用WCF。因此,我并不是在寻找如何创建 Windows 服务的替代方法。

从 VS 2022 生成的代码创建了一个program.cs(无注释),如下所示:

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddGrpc();
var app = builder.Build();
app.MapGrpcService<GreeterService>();
app.MapGet("/", () => "Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");
app.Run();
Run Code Online (Sandbox Code Playgroud)

我能找到的每个示例均与该program.cs 的内容不匹配。此外,所有示例都包含生成的startup.cs 文件。我的项目没有创建startup.cs 文件。所有示例均显示包括 NuGet 包 Microsoft.Extensions.Hosting.WindowsServices 并添加 UseWindowsServices 参数。

Host.CreateDefaultBuilder(args)
    .UseWindowsService()
    ...
Run Code Online (Sandbox Code Playgroud)

我没有 Host 或 CreateDefaultBuilder 方法。我尝试添加以下行:

builder.Host.UseWindowsService();
Run Code Online (Sandbox Code Playgroud)

该程序在 VS 或命令行中运行时可以完美编译并运行。我可以使用 …

c# windows-services grpc

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

TokBox错误:OT.Session:无法连接,会话已未定义

我有一个类似的问题,但无法弄清楚这里发生了什么。我有一个.Net页面,其中包含所有要订阅的TokBox方法。我启动一个新窗口(用于多个流的视频监视器),初始化客户端,将其clientSessions存储在数组中,并在页面上以网格模式显示已订阅的流(在此示例中,仅使用一个客户端)。每次打开页面时,我都会创建并初始化每个客户端会话:

lstSessions[i] = opener.initializeClientSession(apiKey, sessionId, token, $('Player'+i), 'subscribe');
Run Code Online (Sandbox Code Playgroud)

在“打开器”页面中:

function initializeClientSession(apiKey, sessionId, token, container, myAction) {
var clientSession = OT.initSession(apiKey, sessionId);
console.log('initializeClientSession: ' + sessionId);

clientSession.connect(token, function (error) {
    if (error) {
        console.log("ERROR: initializeClientSession: " + myAction + " " + error);
    }
    else {
        console.log("clientSession connected: " + myAction + " " + clientSession.id);

        switch(myAction) {
            case "publish":
                publishClientVideo(clientSession, container);
                break;
            case "subscribe":
                subscribeClientVideo(clientSession, container);
                break;
            case "delay":
                if (inPVM) publishClientVideo(clientSession, container);
                break;
        }
    }
});
return clientSession;
Run Code Online (Sandbox Code Playgroud)

} …

javascript session stream node.js tokbox

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