.net 相关问题

不要用于有关.NET Core的问题。 .NET框架是一个主要为Microsoft Windows操作系统设计的软件框架。它包括基类库,公共语言运行时(通常称为CLR),公共类型系统(通常称为CTS)和动态语言运行时的实现。它支持许多编程语言,包括C#,VB.NET,F#和C ++ / CLI。

需要深入了解NpgSQL DateTimeOffset处理

自版本 6.0 起,如果尝试保存具有非零偏移量的 DateTimeOffset 字段,NpgSQL 会引发异常。 例如: 公开课用户 { 公共 Guid Id { 获取;私人套装; } 公开

回答 1 投票 0

有什么方法可以实现动态的“is”/“as”或者至少是伪造它吗?

我有一个 ConfigValue 类型,它通过 IDynamicMetaObjectProvider 和自定义 DynamicMetaObject 实例的实现公开动态接口。 当然,可以看到这种类型的实例......

回答 4 投票 0

Rider - 无法构建,因为该进程无法访问该文件,因为该文件正在被另一个进程使用

我来这里是为了发布我遇到的错误,它突然出现,但我几个小时没有碰任何东西,我只是想重建,因为我不知道我是否已经构建了。 Fody:发生未处理的异常...

回答 2 投票 0

我无法解析 .net 7 Web api 中的 DateOnly 类型

我有 POST 端点,它接收带有 DateOnly 字段的对象。我尝试使用 https://github.com/maxkoshevoi/DateOnlyTimeOnly.AspNet 包但没有解决我的问题。仍然得到 JSON

回答 1 投票 0

EF Core DbContext 和 Parallel.ForEachAsync 问题

公共类 CarRepository : ICarRepository { .... 公共异步任务 GetById(TId id, CancellationToken CancellationToken) { 返回等待_dbContext.Cars().查找...

回答 2 投票 0

Perfview、BLOCKED_TIME 和垃圾收集中的暂停

我正在尝试通过在 perfview 中分析单线程计算密集型/低 IO .NET 4.7.1 程序来提高其性能,该程序在 r5.8xlarge 实例上的 AWS 中的 Windows Server 2016 上运行...

回答 1 投票 0

使用 JsonResult 返回时 JSON 对象会序列化为空括号

我正在使用 ASP.NET MVC 5 在 .NET Framework 中进行操作。我有一个 MVC 控制器,它使用 Newtonsoft.Json(或 json.net)来构建一个漂亮的 JSON 对象。我遇到的麻烦是当我

回答 2 投票 0

如何在JsonResult中返回Jtoken

请告诉我。如何将此数据返回到 JsonResult 中?我花了2小时也想不出来。 我的任务: 我需要获取这些数据,将其返回到 JsonResult 并在 ajax 中处理它。我会很高兴...

回答 2 投票 0

ScrollViewer 无法与 GroupBox 上的 MouseWheel 配合使用

我正在尝试让滚动查看器在自定义样式的组框中工作。 这是组框的样式: 我正在尝试让滚动查看器在自定义样式的组框中工作。 这是组框的样式: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <!--Set default style of groupbox--> <Style TargetType="GroupBox"> <Setter Property="Margin" Value="0, 10, 0, 0"></Setter> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="GroupBox"> <Border CornerRadius="4" BorderThickness="1" BorderBrush="{StaticResource BorderBrush}" Background="{StaticResource ContentBackgroundBrush}"> <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"> <StackPanel Orientation="Vertical" CanVerticallyScroll="True"> <Label Content="{TemplateBinding Header}" Margin="5,5,0,0" Style="{StaticResource SmallTitle}"></Label> <ContentPresenter Margin="10, 5, 10, 10" RecognizesAccessKey="True" x:Name="CtlGroupboxPresenter" /> </StackPanel> </ScrollViewer> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> 出现了滚动条,但无法使用鼠标滚轮滚动。但是,当我的鼠标悬停在垂直滚动条上时,它会起作用。这似乎是一个跟踪问题。 我看到一些人建议在代码后面添加一些代码以使其正常工作,但由于这是在资源字典中,所以我没有地方可以放置它...... 有谁知道是什么问题吗? 这是 wpf 表单的图像: 组框内的 XAML: <UserControl x:Class="Sun.Plasma.Controls.ViewNews" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"> <DockPanel LastChildFill="True"> <Label DockPanel.Dock="Top" Style="{StaticResource LblTitle}" FontWeight="Bold" FontSize="24" >Latest SUN news &amp; announcements</Label> <StackPanel Orientation="Vertical" VerticalAlignment="Stretch"> <StackPanel Orientation="Vertical" Name="CtlLoadingNews"> <Label Style="{StaticResource LblContent}">Loading content from server...</Label> <ProgressBar IsIndeterminate="True" Height="30" /> </StackPanel> <ListView Background="Transparent" DockPanel.Dock="Bottom" ItemsSource="{Binding NewsFeeds}" BorderBrush="Transparent" Name="CtlNews" Visibility="Collapsed"> <!-- Defining these resources prevents the items from appearing as selectable --> <ListView.Resources> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" /> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" /> <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" /> </ListView.Resources> <ListView.ItemTemplate> <DataTemplate> <StackPanel Orientation="Vertical" Margin="0 0 0 20"> <Label Style="{StaticResource LblTitle}" FontWeight="Bold" Content="{Binding Title}" /> <StackPanel Orientation="Horizontal"> <Label Style="{StaticResource LblFooter}" Content="{Binding PublishDate}" /> <Label Style="{StaticResource LblFooter}">By</Label> <Label Style="{StaticResource LblFooter}" Content="{Binding Authors[0]}" /> <Label Style="{StaticResource LblFooter}"> <Hyperlink RequestNavigate="Hyperlink_RequestNavigate" NavigateUri="{Binding Source}">Read entry</Hyperlink> </Label> </StackPanel> </StackPanel> </DataTemplate> </ListView.ItemTemplate> </ListView> </StackPanel> </DockPanel> 问题在于,ListView内容中的GroupBox阻止了MouseWheel事件冒泡到ScrollViewer。我找到了一个 hacky 解决方案: 您可以处理内部 PreviewMouseWheel 上的 ListView 事件,并直接在滚动查看器上引发 MouseWheel 事件。 private void ListView_PreviewMouseWheel(object sender, MouseWheelEventArgs e) { if (!e.Handled) { e.Handled = true; var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta); eventArg.RoutedEvent = UIElement.MouseWheelEvent; eventArg.Source = sender; //navigate to the containing scrollbar and raise the MouseWheel event (((sender as ListView).Parent as GroupBox).Content as ListView).RaiseEvent(eventArg); } } 再次强调,这不是我特别喜欢的解决方案,因为它依赖于 GroupBox 的布局。 第二种稍微好一点的方法是向 GroupBox 的资源添加样式,在其中向 PreviewMouseWheel 事件添加处理程序: <GroupBox Header="test"> <GroupBox.Resources> <Style TargetType="ScrollViewer"> <EventSetter Event="PreviewMouseWheel" Handler="ScrollViewer_PreviewMouseWheel" /> </Style> </GroupBox.Resources> <!-- your contents --> </GroupBox> 事件处理程序然后执行滚动: private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e) { var scrollViewer = sender as ScrollViewer; double change = e.Delta; double currentPosition = scrollViewer.VerticalOffset; scrollViewer.ScrollToVerticalOffset(currentPosition - change); } 受到@Domysee的启发,但我的事件不是由滚动查看器触发的,可能是因为布局不同 XAML: <GroupBox Header="Services"> <Grid PreviewMouseWheel="OnScroll"> <ScrollViewer x:Name="_scrollViewer" VerticalScrollBarVisibility="Auto"> <StackPanel Orientation="Vertical"> <ScrollViewer VerticalScrollBarVisibility="Auto"> <ItemsControl ItemsSource="{Binding Services}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <UniformGrid Columns="2" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </ScrollViewer> <Button Width="50" HorizontalAlignment="Left" Command="{Binding NewServiceCommand}" Content="+" /> </StackPanel> </ScrollViewer> <Grid <!-- overlay goes here --> </Grid> </Grid> </GroupBox> 背后代码: private void OnScroll(object sender, MouseWheelEventArgs e) { double change = e.Delta; double currentPosition = _scrollViewer.VerticalOffset; _scrollViewer.ScrollToVerticalOffset(currentPosition - change); }

回答 2 投票 0

如何在 C# 中正确读取 CSV 文件中的捷克语字符?

对于我的 C# WPF 应用程序,我需要导入 CSV 文件(用 ; 分隔)。 CSV 文件中有许多不同的列(其中一些甚至是空的)。第一列和第二列包含名称和s...

回答 1 投票 0

ImageList 与资源:如何在 Winforms 中组织图像?

TLDR: 在启动时创建 ImageList 并通过其索引访问每个图像是否仍然很常见,或者资源是可行的方法吗? 详细问题: 我目前正在开发软件,但尚未...

回答 1 投票 0

如何使用 C# 中的 Graph API 更新用户个人资料图像

我想使用 C# 中的 Graph API 更新我的用户个人资料图像和另一个用户的个人资料图像。 我拥有 Microsoft Azure 中使用代码执行任何操作的所有权限。 怎么可能。 请建议...

回答 1 投票 0

在unity3d中使用open ai时出现IHttpClientFactory不存在的错误如何解决?

错误出现在第38行 在这部分代码的最后一行: 公共 IHttpClientFactory HttpClientFactory { 获取;放; } 完整部分: 使用 OpenAI_API.Audio; 使用 OpenAI_API.Chat; 使用

回答 1 投票 0

如何在c# .net标准中动态加载本机dll?

我想对 .NET Standard 中的本机 DLL 使用类似于 NativeLibrary.TryLoad 的东西。但我找不到它的方法。有没有好的方法可以做到这一点? 我知道我可以做类似的事情 [DllImport(@&

回答 1 投票 0

如何在 Mac OSX 上使用 Net.IBM.Data.Db2?

我有一个使用 Net.IBM.Data.Db2 的 dotnet 核心项目,它在 Windows 和 Linux 上运行良好。我现在尝试使用 Net.IBM.Data.Db2-osx 让它在 Apple Macbook M3 Pro 上运行,但我...

回答 1 投票 0

Azure.Messaging.ServiceBus 无法配置 TransportType

我目前正在尝试使用此入门页面之后的 Azure.Messaging.ServiceBus 包。我遇到了一个问题,我会收到以下错误: Azure.消息传递.Serv...

回答 3 投票 0

如何在单文件exe的初始提取阶段显示启动屏幕

我有一个 WinForms 应用程序,它捆绑为单个文件 exe。在新系统上首次启动期间,exe 总是需要大约 20 秒才能完成将所有必需文件提取到

回答 1 投票 0

有没有办法记录或拦截第一次机会异常

如果不使用探查器,在运行的程序中是否有任何方法可以检测第一次机会异常?理想情况下,我想记录更详细的状态信息,一旦

回答 3 投票 0

在 .NET 依赖注入中解析服务时如何注入运行时参数?

我有一个存储库类,它有一个使用文件系统的实现。 存储库抽象 公共接口IPersonRepository { IEnumerable GetAll(); ...

回答 1 投票 0

为什么我的删除级联策略无法正常工作

我有 2 个表,分别称为“域”和“域主题”。它具有一对一的关系。这里是 2 个模型类。 公共类域 { 公共 int OrganizationDomainId { 获取;放; } ...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.