小编Ast*_*aar的帖子

完全卸载VS Code扩展

从VS Code的最新版本开始,每当我打开一个C#文件时都会出错(我已经安装了由OmniSharp驱动的csharp语言扩展).这是我得到的错误:

在此输入图像描述

我尝试卸载扩展并重新安装它,同样的问题.我完全卸载了应用程序并重新安装了它 - 但是当我这样做时,我的扩展仍然安装(例如Python和reStructuredText仍然存在).我再次卸载并删除了%USER%\AppData\Roaming|Local\Code目录.当我重新安装时,扩展程序仍在那里.

如何完全删除已安装的扩展程序?在打开OmniSharp扩展崩溃的bug之前,我想确定我是从头开始的.

visual-studio-code

46
推荐指数
8
解决办法
5万
查看次数

无法序列化内容类型的响应正文

我正在构建一个使用Controllers和ApiControllers的MVC4应用程序.我修改了默认Web API路由以包含操作名称.当我尝试获取基准列表时,我收到此错误消息:

'ObjectContent`1'类型无法序列化内容类型'application/json的响应主体; 字符集= UTF-8'

InnerException就是这个(我在这种情况下返回JSON,与XML相同):

"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "Error getting value from 'IdentityEqualityComparer' on 'NHibernate.Proxy.DefaultLazyInitializer'.",
"ExceptionType": "Newtonsoft.Json.JsonSerializationException",
"StackTrace": " at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeISerializable(JsonWriter writer, ISerializable value, JsonISerializableContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty) …
Run Code Online (Sandbox Code Playgroud)

rest fluent-nhibernate asp.net-mvc-4 asp.net-web-api

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

流利的NHibernate"无法解决财产问题"

我已经阅读了很多关于同样错误的问题,但没有找到与我的确切问题相符的问题.我正在尝试使用Fluent NHibernate访问对象的属性,它本身是根对象的一部分.一些答案说我需要使用投影,其他我需要使用连接,我认为它应该通过延迟加载.

这是我的两个类以及Fluent映射:

艺术家班

public class Artist
{
    public virtual int Id { get; set; }
    public virtual string Name { get; set; }
    public virtual IList<Album> Albums { get; set; }
    public virtual string MusicBrainzId { get; set; }
    public virtual string TheAudioDbId { get; set; }

    public Artist() { }
}

public class ArtistMap : ClassMap<Artist>
{
    public ArtistMap()
    {
        LazyLoad();
        Id(a => a.Id);
        Map(a => a.Name).Index("Name");
        HasMany(a => a.Albums)
            .Cascade.All();
        Map(a => a.MusicBrainzId);
        Map(a => a.TheAudioDbId);
    } …
Run Code Online (Sandbox Code Playgroud)

c# nhibernate fluent-nhibernate queryover

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

C#/ NHibernate:关联引用未映射的类

几个小时以来,我一直在努力解决这个NHibernate问题.我在网上和NHibernate文档上进行了广泛的研究,我对这个问题没有任何意义.我对NHibernate相对较新,并且喜欢它.在那种情况下,它让我发疯了.

我正在为一个网站写一个小的"民意调查"模块.我有几个班(Poll,PollVote和PollAnswer).主要的一个,民意调查,就是造成这个问题的人.这就是这个类的样子:

public class Poll
    {
        public virtual int Id { get; set; }
        public virtual Site Site { get; set; }
        public virtual string Question { get; set; }
        public virtual bool Locked { get; set; }
        public virtual bool Enabled { get; set; }
        public virtual ICollection<PollAnswer> AnswersSet { get; set; }
        public virtual ICollection<PollVote> VotesSet { get; set; }
    }
Run Code Online (Sandbox Code Playgroud)

这就是映射的样子:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                   assembly="Folke"
                   namespace="Folke.Code.Domain">
  <class name="Poll">
    <id name="Id">
      <generator class="native"></generator>
    </id>
    <property …
Run Code Online (Sandbox Code Playgroud)

c# nhibernate

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

MVC6自托管wwwroot内容返回404,IIS Express没有

我正在玩ASP.NET5/MVC6,我构建了一个小型Web应用程序.当我使用Visual Studio的IIS Express调试服务器时,一切都按预期工作.但是当我使用"web"服务器配置文件(意思是WebListener服务器)时,只有我的MVC控制器和视图才有效.但是,存储在"wwwroot"下的所有内容都返回404.我在那里放了CSS,JS和图像文件.

一旦切换回IIS Express,就会正确获取内容.

完整的源代码可以在那里找到:https://github.com/acastaner/acastaner.fr-mvc6

这是我的Startup类:

public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
        }

        public void Configure(IApplicationBuilder app)
        {
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });
            });
        }
    }
Run Code Online (Sandbox Code Playgroud)

这是我的project.json文件:

{
    "webroot": "wwwroot",
    "version": "1.0.0-*",
    "dependencies": {
        "Microsoft.AspNet.Server.IIS": "1.0.0-beta3",
        "Microsoft.AspNet.Diagnostics": "1.0.0-beta3",
        "Microsoft.AspNet.Mvc": "6.0.0-beta3",
        "Microsoft.AspNet.Server.WebListener": "1.0.0-beta3"
    },
    "frameworks": {
        "aspnet50": { },
        "aspnetcore50": { }
    },
    "bundleExclude": [
        "node_modules",
        "bower_components",
        "**.kproj",
        "**.user",
        "**.vspscc" …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc owin asp.net-core-mvc asp.net-core

9
推荐指数
1
解决办法
2624
查看次数

在MVC6中的IAuthenticationFilter等价物

我正在将Web Api 2项目移动到MVC 6,因为Microsoft正在合并ASP.NET 5中的两个API.在我的WebApi项目中,我有一个自定义属性过滤器类,它将使用以下组合进行身份验证,授权和防止事务重放.公钥,私钥和HMAC认证(基本上,这样做一些调整,以适合我的项目).

现在在MVC6中,据我所知,我必须停止使用Microsoft.Web.Http命名空间中的任何内容,而是使用Microsoft.AspNet.Mvc.所以我已经这样做了,但是Microsoft.AspNet.Mvc.Filters似乎没有任何Web Api 2的等价物IAuthenticationFilter.

这对我来说是一个问题,因为我的客户AuthenticationFilter实现了所有IAuthenticationFilter,其中包含所有逻辑.更重要的是,它使用Context临时存储帐户的公钥,因此我的控制器可以访问它以依次加载帐户.

所以我的问题是,在MVC6中过滤请求的正确方法是什么,使用类似于身份验证过滤器的类拦截请求并返回相应的状态代码?我找不到任何专门针对这些细节的文章(它们都倾向于涵盖MVC5).

asp.net-web-api2 asp.net-core-mvc

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

使用ASP.NET刷新UpdatePanel中的Repeater控件

我正在尝试编写一个页面,您可以在其中发布评论而无需重新加载整个页面.使用Repeater控件显示注释.模板看起来像这样:

    <asp:UpdatePanel runat="server" ID="commentsUpdatePanel" UpdateMode="Conditional">
        <ContentTemplate>
        <!-- Comments block -->
        <div class="wrapper bloc content">
            <h3><img src="img/comments.png" alt="Comments" />&nbsp;Comments</h3>                                     
            <p><asp:Label ID="viewImageNoComments" runat="server" /></p>
            <asp:Repeater ID="viewImageCommentsRepeater" runat="server">
                <HeaderTemplate>
                    <div class="float_box marge wrapper comments">
                </HeaderTemplate>
                <ItemTemplate>
                    <div class="grid_25">
                        <span class="user"><%#Eval("username")%></span><br />
                        <span style="font-size:x-small; color:#666"><%#Eval("datetime") %></span>
                    </div>
                    <div class="grid_75">
                        <p align="justify"><%#Eval("com_text") %></p>
                    </div>
                </ItemTemplate>
                <FooterTemplate>
                    </div>
                </FooterTemplate>
            </asp:Repeater>
        </div>
        <!-- Post comment block -->
        <div class="wrapper bloc content">
            <h3><a id="post_comment" name="post_comment"><img src="img/comment_edit.png" alt="Comments" /></a>&nbsp;Post 
                a comment</h3>
            <p class="description">Please be polite.</p>
            <p>
                <asp:Label ID="postCommentFeedback" runat="server" …
Run Code Online (Sandbox Code Playgroud)

c# asp.net updatepanel repeater

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

通过RegEx从Open3.popen3的stdout中提取值并存储它

我是Ruby的新手,似乎无法找到获取外部命令输出的方法.我需要提取命令返回的值.现在我有这样的事情:

stdin, stdout, stderr, wait_thr = Open3.popen3("#{path}/foobar", configfile)

if /exit 0/ =~ wait_thr.value.to_s
    runlog.puts("Foobar exited normally.\n")
    puts "Test completed."
    someoutputvalue = stdout.read("TX.*\s+(\d+)\s+")
    puts "Output value: " + someoutputvalue
end
Run Code Online (Sandbox Code Playgroud)

但我显然没有在stdout上使用正确的方法,因为Ruby告诉我它不能将String转换为Integer.

这样做的正确方法是什么?我在文档中找不到stdout可用的方法.使用28我正在使用Ruby 1.9.3.

更新

为了清楚起见,我正在尝试读取程序的输出,应用正则表达式,并将提取的值存储到变量中供以后使用.

因此,例如,如果输出是"TX So so so:28",我想只获得"28"(我验证上面的正则表达式匹配我需要匹配的内容,我只是想知道如何将所提取的值存储在一个变量).

ruby regex regex-group

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

Visual Studio 2008中的PostgreSQL数据连接/服务器资源管理器

我正在尝试从Visual Studio 2008"服务器资源管理器"面板中找到一种浏览PostgreSQL数据库的方法.我下载了Npgsql,但据我所知,这只是代码本身的库,而不是服务器资源管理器.

database postgresql visual-studio-2008

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

MVC5自托管OWIN返回404

我使用MVC5和ASP.NET 4.5创建了一个简单的Web应用程序.使用该Web应用程序作为启动项目在本地运行时工作正常.我正在尝试将其转换为OWIN自托管应用程序,因此我在项目中添加了一个Console程序,并将其设置为Visual Studio中的启动项目(我正在使用2013社区).

这是我的Program类:

class Program
    {
        static void Main(string[] args)
        {
            using (Microsoft.Owin.Hosting.WebApp.Start<WebApp.Startup>("http://localhost:9000"))
            {
                Console.WriteLine("Press [enter] to quit...");
                Console.ReadLine();
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

运行正常,不会触发任何错误.但是,当我尝试访问该URL时,我得到的只是一个空白页面,实际上是一个404错误页面(我在页面中没有任何内容,但查看网络跟踪,我看到响应是404) .

这是WebApp的Startup类:

public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
        }
    }
Run Code Online (Sandbox Code Playgroud)

是的,它是空的,因为我没有太多事情要做(没有要触发的身份验证或数据库架构更新).我确定我错过了一些明显的东西,但我似乎找不到任何文章详细说明了为MVC5项目正确地进行OWIN连接所需的内容.

asp.net-mvc owin

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

IConfiguration不包含Get()的定义(EF7,vNext)

我正在摆弄EntityFramework 7和ASP.NET 5/vNext.我按照本教程.但是,当我尝试从config.json文件中获取连接字符串时,我遇到了一个问题:

'IConfiguration' does not contain a definition for 'Get' and no extension method 'Get' accepting a first argument of type 'IConfiguration' could be found (are you missing a using directive or an assembly reference?)

我不认为我错过了一个引用,但这里是project.json依赖项部分:

  "dependencies": {
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta5",
    "Microsoft.AspNet.Mvc": "6.0.0-beta5",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
    "System.Net.Http": "4.0.0-beta-23019",
    "Microsoft.AspNet.WebApi": "5.2.3",
    "Microsoft.AspNet.WebUtilities": "1.0.0-beta5",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
    "Microsoft.Owin.Security": "3.0.1",
    "Microsoft.AspNet.Hosting": "1.0.0-beta5",
    "Kestrel": "1.0.0-*",
    "Microsoft.AspNet.WebApi.Owin": "5.2.3",
    "Microsoft.Owin.Security.OAuth": "3.0.1",
    "Microsoft.AspNet.Mvc.Core": "6.0.0-beta5",
    "Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-beta5",
    "Microsoft.AspNet.Identity.Owin": "2.2.1",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta5",
    "EntityFramework.SqlServer": "7.0.0-beta8-15186",
    "EntityFramework.Commands": …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc entity-framework asp.net-core

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

为什么我的DataTable总是返回"true/false"但从不返回字符串?

我正在尝试使用由MySqlDataAdapter填充的DataTable,其中包含博客条目的注释列表.由于某些原因,如果字段"anonymous"设置为"1",则username字段为空,应替换为指定的字符串.

我遇到的问题是,每当我尝试获取字段的值时,我会得到"true"或"false".我的代码看起来像这样:

DataTable modifiedComments = new DataTable();
// The function GetCommentsById() returns a MySqlDataAdapter with the result of the query
MySqlDataAdapter commentsContainer = Wb.Entry.GetCommentsById(imageId);
commentsContainer.Fill(modifiedComments);
commentsContainer.Dispose();

    foreach (DataRow row in modifiedComments.Rows)
        {
            string status;
            // This never returns true, so we always get into the else
            if (row["anonymous"] == "1")
            {
                    status = "You are anonymous";
            }
            else
            {
                    status = "You are not anonymous";
            }
        }

        viewImageCommentsRepeater.DataSource = modifiedComments;
        viewImageCommentsRepeater.DataBind();
Run Code Online (Sandbox Code Playgroud)

c# asp.net datatable datarow

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

使用Fluent NHibernate和MVC 3进行SqlDateTime溢出

我正在使用FNH生成ASP.NET MVC3应用程序中使用的大约30个类的映射.我正在攻击MSSQL Express 10.我创建了一些代码,允许我使用一些数据填充数据库以用于开发目的.但是,当我尝试保存帐户实例时,我收到以下错误消息:

System.Data.SqlTypes.SqlTypeException:SqlDateTime溢出.必须在1/1/1753 12:00:00 AM和12/31/9999 11:59:59 PM之间.

这是因为Account.CreationDate属性,它是一个DateTime.我环顾四周,MSSQL和.NET中的DateTime实际上并不相同.我试过,通过FNH映射强制列为"datetime2",但这似乎没有帮助.

这是我的帐户类(简化):

public class Account
{
    public virtual int Id { get; set; }
    public virtual string Comment { get; set;}
    public virtual DateTime CreationDate { get; set;}
    public virtual string Email { get; set;}
    public virtual string Password {get ; set;}
    public virtual string Locale {get; set;}

    public Account(string password, string email)
    {
        this.Email = email;
        SetNewPassord(password);
        this.CreationDate = DateTime.Now;
        this.Locale = "en-US";
    }
}
Run Code Online (Sandbox Code Playgroud)

和FNH映射:

public class AccountMap : …
Run Code Online (Sandbox Code Playgroud)

c# fluent-nhibernate sql-server-express asp.net-mvc-3

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