小编Chr*_*oll的帖子

如何在PostgreSQL中运行ad-hoc脚本?

我试图在PostgreSQL 9.2中运行它:

RAISE NOTICE 'hello, world!';
Run Code Online (Sandbox Code Playgroud)

服务器说:

Error : ERROR:  syntax error at or near "RAISE"
LINE 1: RAISE NOTICE 'hello, world!'
        ^
Run Code Online (Sandbox Code Playgroud)

为什么?

postgresql postgresql-9.2

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

.Net Core中缺少IsGenericType和IsValueType?

我在.Net 4.6.2中有这个代码,现在尝试转换为.Net核心但是我收到了错误

错误CS1061'Type'不包含'IsGenericType'的定义,也没有扩展方法'IsGenericType'接受类型'Type'的第一个参数(你是否缺少using指令或汇编引用?)

public static class StringExtensions
{
    public static TDest ConvertStringTo<TDest>(this string src)
    {
        if (src == null)
        {
            return default(TDest);
        }           

        return ChangeType<TDest>(src);
    }

    private static T ChangeType<T>(string value)
    {
        var t = typeof(T);

        // getting error here at t.IsGenericType
        if (t.IsGenericType && t.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
        {
            if (value == null)
            {
                return default(T);
            }

            t = Nullable.GetUnderlyingType(t);
        }

        return (T)Convert.ChangeType(value, t);
    }
}
Run Code Online (Sandbox Code Playgroud)

什么相当于.Net Core?

UPDATE1

令人惊讶的是,当我调试代码时,我看到变量tIsGenericType 属性,但我不能IsGenericType在代码中使用.不确定我需要添加的原因或名称空间.我已经加入using Systemusing System.Runtime两个命名空间

在此输入图像描述

c# .net-core coreclr asp.net-core

23
推荐指数
1
解决办法
4618
查看次数

如何记录WCF消息内容?

在此输入图像描述

我认为这很简单,但我看不出如何告诉WCF记录消息体.我有:

<system.diagnostics>
  <sources>
    <source name="System.ServiceModel" switchValue="Verbose">
      <listeners>
        <add type="System.Diagnostics.DefaultTraceListener" name="Default">
          <filter type="" />
        </add>
        <add type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EntLibLoggingProxyTraceListener,Microsoft.Practices.EnterpriseLibrary.Logging"
          name="traceListener">
          <filter type="" />
        </add>
      </listeners>
    </source>
  </sources>
</system.diagnostics>
<system.serviceModel>
   <diagnostics>
     <messageLogging logEntireMessage="true" logMalformedMessages="true"
       logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="false" />
   </diagnostics>
   ...etc..,
   ...etc...
</system.Model>
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
   <listeners>
     <add fileName="_trace-xml.log"
                listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.XmlTraceListenerData,Microsoft.Practices.EnterpriseLibrary.Logging"
                traceOutputOptions="None"
                type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.XmlTraceListener,Microsoft.Practices.EnterpriseLibrary.Logging"
        name="XML Trace Listener" />      
     ...etc... other listeners
  </listeners>
  ...etc...
</loggingConfiguration>
Run Code Online (Sandbox Code Playgroud)

但我记录的只是关于消息的内容,而不是消息体.我需要更改为记录消息内容?

.net wcf logging

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

如何为 .NET Core 项目指定程序集版本?

我注意到在新的 .NET Core 项目中没有AssemblyInfo.cs创建文件。我已经看到您仍然可以设置诸如AssemblyVersion等等之类的程序集属性。

使用 AssemblyInfo.cs 文件还有什么正当理由吗?

.net c# .net-core

21
推荐指数
5
解决办法
9712
查看次数

Bash正则表达式 - 似乎无法匹配\ s,\ S等

我有一个脚本试图从gparted获取信息块.

我的数据看起来像:

Disk /dev/sda: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  316MB   315MB   primary  ext4            boot
 2      316MB   38.7GB  38.4GB  primary  ext4
 3      38.7GB  42.9GB  4228MB  primary  linux-swap(v1)

log4net.xml
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  316MB   315MB   primary  ext4            boot
 5      316MB   38.7GB  38.4GB  primary  ext4
 6      38.7GB  42.9GB  4228MB …
Run Code Online (Sandbox Code Playgroud)

regex bash

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

如何在.NET Core上构建多目标解决方案?

我有多目标csproj文件的解决方案:

<PropertyGroup>
  <TargetFrameworks>net45;netstandard1.6</TargetFrameworks>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)

要么

<PropertyGroup>
  <TargetFrameworks>net45;netcoreapp1.1</TargetFrameworks>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)

我正在尝试在Linux上构建此解决方案的.NET Core部分,但无法管理它.如果我跑

dotnet build
Run Code Online (Sandbox Code Playgroud)

它构建所有目标:netcoreapp1.1,netstandard1.6并且net45在net45上失败,因为.NET Core不在Linux上提供.NET 4.5平台.我试图通过将mono指定为构建框架来解决此问题,但解决方案很复杂,而且并非所有.NET 4.5都支持单声道.但是,这可以帮助其他人避免can't find .NETFramework v4.5运行:

FrameworkPathOverride=/usr/lib/mono/4.5/ dotnet restore
FrameworkPathOverride=/usr/lib/mono/4.5/ dotnet build
Run Code Online (Sandbox Code Playgroud)

当我跑步时,dotnet build /p:TargetFramework=netcoreapp1.1我得到了很多错误,我认为因为netstandard1.6没有构建项目.

如果我通过

  dotnet build /p:TargetFrameworks=netcoreapp1.1\;netstandard1.6
Run Code Online (Sandbox Code Playgroud)

我明白了

MSBUILD : error MSB1006: Property is not valid.
Switch: netstandard1.6
Run Code Online (Sandbox Code Playgroud)

如何从命令行同时传递netcoreapp1.1netstandard1.6定位框架到msbuild?

我知道我可以添加额外的属性并根据它进行条件编译,但我不想更改csproj以使其解决方法.

linux msbuild csproj .net-core

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

将聚合物应用程序提供给/不在根目录的路径

因此,我想要使用新的Polymer应用程序做的第一件事是部署到现有网站上的目录.似乎唯一有用的就是部署到root /.

我们来看看Shop的例子.我做:

  1. polymer init 并选择商店
  2. polymer build
  3. Robocopy.exe .\build\bundled\ C:\inetpub\wwwroot\p\ /MIR
  4. start http://localhost/p/

你看我在Windows上.我认为使用IIS是无关紧要的,因为我只依靠服务器来提供静态内容.

我需要在商店模板中编辑什么才能使其在网址上运行http://localhost/p/

polymer

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

使用 Google.Api OAuth 2 时拒绝访问路径“C:\Windows\system32\config\systemprofile”

我正在使用Google Calendar Api我的一个项目。我不知道如何,但下面显示的错误令人不安。

这是错误

错误堆栈跟踪

里面的代码AppFlowMetadata

public class AppFlowMetadata : FlowMetadata
{
    private static readonly IAuthorizationCodeFlow flow =
        new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
        {
            ClientSecrets = new ClientSecrets
            {
                ClientId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
                ClientSecret = "xxxxx_xxxxxxxxxxxxxxxxx"
            },
            Scopes = new[] { CalendarService.Scope.Calendar },
            DataStore = new FileDataStore("Calendar.Api.Auth.Store")
        });

    public override string GetUserId(Controller controller)
    {
        var user = controller.Session["UserID"];

        if (user == null)
        {
            user = Guid.NewGuid();
            controller.Session["UserID"] = user;
        }
        return user.ToString();

    }

    public override IAuthorizationCodeFlow Flow
    {
        get { return …
Run Code Online (Sandbox Code Playgroud)

.net model-view-controller google-calendar-api google-api

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

文件后面的ASP.NET代码未嵌套在Visual Studio中的相关aspx文件下

在使用.NET Framework 4.0的C#ASP.NET网站中,我有几个页面,其中相关的.cs文件不在其相关的aspx文件下。我最近将文件移到了子目录。我有10页,其中8页的移动效果很好,.cs文件位于aspx下。但是,对于两个页面,.cs文件现在不再显示在aspx文件下方。如何解决此问题,以便在aspx文件下面正确显示CS?当我比较标记页面的顶部时,两个问题页面看起来与其他8个页面一样。我在那里看不到任何问题。

asp.net visual-studio

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

如何模拟Amazon S3 Client进行.NET单元测试

我注意到重要成员AmazonS3Client虚拟的,所以Mock<AmazonS3Client>应该很容易.但

new Mock<AmazonS3Client>()
Run Code Online (Sandbox Code Playgroud)

使用Moq,给我一个错误,说没有效果RegionEndpoint.

显然需要更多一点.

.net c# unit-testing moq amazon-s3

4
推荐指数
2
解决办法
4160
查看次数