小编Jer*_*ney的帖子

Xamarin 无法访问对隐藏代码的控制

对于我的 Xamarin Forms 项目(最新版本 1.3),当我在 Xamarin Studio(最新版本,5.5.4)中创建视图时,我将视图定义如下:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="FormsDemo.Register">
  <ContentPage.Content>

    <Grid>
      <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="100" />
        <ColumnDefinition />
      </Grid.ColumnDefinitions>

      <Label Grid.Row="0" Grid.Column="0" Text="First Name" />
      <Entry x:Name="FirstName" Grid.Row="0" Grid.Column="1" />

      <Label Grid.Row="1" Grid.Column="0" Text="Last Name" />
      <Entry x:Name="LastName" Grid.Row="1" Grid.Column="1" />

      <Label Grid.Row="2" Grid.Column="0" Text="Email" />
      <Entry x:Name="Email" Grid.Row="2" Grid.Column="1" />

      <Button x:Name="SaveButton" Grid.Row="3" Grid.Column="0" Text="Login" />
    </Grid>

  </ContentPage.Content>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)

但是,在我的代码隐藏中,根本找不到任何对其名称的控件的引用。以下代码出错(由注释指出):

using System;
using System.Collections.Generic;
using …
Run Code Online (Sandbox Code Playgroud)

.net c# code-behind xamarin xamarin.forms

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

.NET Core Web API 部署到 Azure 后无法工作

我有一个简单的 .NET Core Web API 应用程序\xe2\x80\x94,这是创建新项目时由 Visual Studio 创建的应用程序。我想通过 FTP 将其部署到 Azure 应用服务,作为 Team Foundation Server (TFS) 2017 构建作业的一部分,这是成功的:

\n\n

在此输入图像描述

\n\n

但是,当尝试发出GET如下 URL 之类的请求时:

\n\n
http://somerandomname.azurewebsites.net/api/values\n
Run Code Online (Sandbox Code Playgroud)\n\n

我收到的只是一个 404,其中包含以下文字:

\n\n
\n

您正在查找的资源已被删除、更名或暂时不可用。

\n
\n\n

从 Kudu 中,我收到以下错误:

\n\n

在此输入图像描述

\n\n

我缺少什么?

\n

azure .net-core azure-web-app-service asp.net-core-webapi

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

Putting Views and Controllers in a different project than the ASP.NET Core Web app

I am trying to split up my ASP.NET Core 3.0 pre-release 9 MVC app into different projects. For example, I\xe2\x80\x99d like to have everything related to one subdomain go into a project called Website.SubdomainA and the other one into Website.SubdomainB.

\n\n

我尝试使用 Razor 类库来完成此任务。根据MSDN,这些应该能够包含以下内容:

\n\n
\n

Razor 视图、页面、控制器、页面模型、Razor 组件、视图组件和数据模型可以构建到 Razor 类库 (RCL) 中。

\n
\n\n

所以我继续创建了一个“RCL”,如下所示:

\n\n
<Project Sdk="Microsoft.NET.Sdk.Razor">\n  <PropertyGroup>\n    <TargetFramework>netstandard2.1</TargetFramework>\n    <RazorLangVersion>3.0</RazorLangVersion>\n  </PropertyGroup>\n</Project>\n
Run Code Online (Sandbox Code Playgroud)\n\n

然后我复制了我的控制器和视图\xe2\x80\x94,但是由于某种原因,它找不到任何包含基类的程序集ControllerRouteAttribute以及包含在Microsoft.AspNetCore.Mvc namespace.

\n\n

此外,我的视图无法编译,因为它们找不到所需的程序集,以及类似的东西Layout = "Test" get …

c# razor asp.net-core-mvc asp.net-core asp.net-core-3.0

6
推荐指数
1
解决办法
2851
查看次数

从 .NET Core 2.2 迁移到 3.0-preview-9 后,模型绑定停止工作

我有一个 Angular 前端应用程序和一个 ASP.NET Core 后端应用程序。一切都很好,直到我决定从 ASP.NET Core 2.2 迁移到 3.0-preview-9。

例如,我有一个 DTO 类:

public class DutyRateDto
{
    public string Code { get; set; }
    public string Name { get; set; }
    public decimal Rate { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

以及一个示例 JSON 请求:

{
    "name":"F",
    "code":"F",
    "rate":"123"
}
Run Code Online (Sandbox Code Playgroud)

在迁移之前,这是一个有效的请求,因为它123被解析为小数。但是现在,在迁移后,我收到此正文的 HTTP 400 错误:

{
    "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
    "title": "One or more validation errors occurred.",
    "status": 400,
    "traceId": "|3293cead-4a35656a3ae5e95b.",
    "errors": {
        "$.rate": [
            "The JSON value could not be converted to …
Run Code Online (Sandbox Code Playgroud)

c# .net-core asp.net-core angular asp.net-core-3.0

6
推荐指数
1
解决办法
683
查看次数

Spark中是否可以插入临时表?

我使用 Databricks 和 Apache Spark 2.4 测试了以下查询:

%sql

<step1>
create temporary view temp_view_t
as select 1 as no, 'aaa' as str;

<step2>
insert into temp_view_t values (2,'bbb');
Run Code Online (Sandbox Code Playgroud)

然后我收到此错误消息。

SQL 语句错误: AnalysisException:不允许插入基于 RDD 的表。;; 'InsertIntoTable 项目 [1 AS no#824,aaa AS str#825],false,false +- LocalRelation [col1#831,col2#832]

我的问题是

  1. Spark中无法插入临时表吗?
  2. 如何在 Spark sql 中创建临时数据?

谢谢。

temporary apache-spark

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

C# .NET 中的“模块”关键字是什么?

我正在学习 C# 并遇到了关键字module. 我想知道moduleC# 中的this关键字是什么以及它有什么用处。例如,考虑以下代码:

[module: Test]
public class TestAttribute : Attribute
{
}
Run Code Online (Sandbox Code Playgroud)

.net c# fody .net-attributes

6
推荐指数
1
解决办法
319
查看次数

为什么 .NET Core 和 .NET 5 会生成可执行文件?

我有一个问题,我很困惑。我理解.NET的方式是这样的:

  • C# 应用程序(源代码)->
  • csc.exe (编译器)->
  • .NET 应用程序(在 MSIL 中)

如果是这样,为什么构建 .NET 应用程序的输出是 Windows 可执行文件?我认为整个想法是你的源代码编译成 MSIL,它针对本地安装的 CLR。但是,.NET Core 和 .NET 5 都会生成一个 Windows 可执行文件,它运行在操作系统之上,而不是在虚拟机中。

This is unlike Java, which compiles to a .class bytecode file (not an .exe), and those files do run atop a virtual machine (or, later, you can package all the class files into a .jar).

What I'm trying to ask is: Why doesn't the C# compiler generate a specific application file type that runs atop …

.net cil .net-core .net-5

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

通过 Visual Studio 2022 发布具有 C# 10 隐式使用的 .NET 6 项目

从 Visual Studio 2022 发布配置文件将启用了C# 10 的 ASP.NET Core 6 Web 应用程序发布<ImplicitUsings />到 Azure 应用服务时,发布构建由于缺少using语句而失败。

\n

背景

\n

C# 10 引入了新的隐式 using功能,其中某些using指令被视为基于 SDK 的全局 using指令。可以通过以下配置启用此功能csproj

\n
<PropertyGroup>\n    <ImplicitUsings>enable</ImplicitUsings>\n</PropertyGroup>\n
Run Code Online (Sandbox Code Playgroud)\n

这与本地构建的预期完全一致。例如,当针对Microsoft.NET.Sdk.WebSDK 时,我可以删除、、、 &cusing的指令。SystemSystem.Collections.GenericSystem.Linq

\n

发布错误

\n

但是,当从 Visual Studio 2022 发布配置文件发布到 Azure 应用服务时,生成输出会显示如下错误:

\n
C:\\Code\\MyWebApp\\MyClass.cs(41,25): Error CS0246: The type or namespace name \'IEnumerable<>\' could not be found (are you missing a …
Run Code Online (Sandbox Code Playgroud)

.net msdeploy visual-studio-2022 c#-10.0

6
推荐指数
1
解决办法
5183
查看次数

如何避免在 ASP.NET Core MVC 中将视图组件 cshtml 命名为“Default.cshtml”?

看来在 ASP.NET Core MVC 中,如果我想使用视图组件,我必须将它们放入Views\\Shared\\Components\\[ViewComponentName],然后将文件命名为“Default.cshtml”。

\n

这是相当令人沮丧的,因为在一个大型项目的开始,我正在帮助从 Perl CGI 进行移植,我正在创建大量的视图组件,并在 Visual Studio 中拥有五个选项卡,全部命名为Default.cshtml是令人困惑的。

\n

有什么办法可以避免这种命名约定吗?也许甚至可以将它们从文件夹中取出,以便文件看起来像\xe2\x80\xa6?

\n
Views\\Shared\\Components\\[ViewComponentName].cshtml\n
Run Code Online (Sandbox Code Playgroud)\n

我不知道是否只有一些设置可以调整或者什么。大多数情况下,我对 ASP.NET 非常陌生,并且仍在摸索中。使用 ASP.NET Framework 而不是 ASP.NET Core一种选择,但我不想这样做,因为很多样板已经完成。

\n

ViewComponents 的文档是这样说的:

\n
\n

我们建议您将视图文件命名为 Default.cshtml 并使用 Views/Shared/Components/{View Component Name}/{View Name} 路径。

\n
\n

这让我认为有一种方法可以绕过这个限制,但它没有具体说明它是如何工作的或者它会是什么样子。

\n

asp.net-core-mvc asp.net-core asp.net-core-viewcomponent view-components

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

移动网络上的 iframe 上的按钮不可点击

我试图将按钮绝对放置在iframe上。但是,当在移动网络中查看我的应用程序时,不会记录任何按钮单击;相反,点击会在其下方的 iframe 上注册。

完全相同的实现也适用于非移动网络。

这是用于可视化目的的实现图片

这是我当前使用的代码:

<div style={{ width: '100vw', height: '100vh', display: 'flex', position: 'relative' }} />
   <button
      style={{ position: 'absolute', top: 0, bottom: 0, zIndex: 1  }}
      onClick={() => console.log('button clicked')}
   >
      click here
   </button>

   <iframe style={{ width: '100%' }} src={src} />
</div>
Run Code Online (Sandbox Code Playgroud)

我尝试过的其他一些事情:

  • z-index将的设置iframe为较低的数字(iframe仍然会被点击)
  • 禁用(pointer-events按钮iframe点击仍未注册)
  • 将其包裹button在一个div
  • 将其包裹iframe在一个div
  • 停止传播点击事件button

iframe mobile mobile-safari stoppropagation reactjs

5
推荐指数
0
解决办法
457
查看次数