小编jmo*_*era的帖子

在Visual Studio 2010中调试和修复ObjectDisposedException

编辑XAML文件时,我注意到以下错误:

System.ObjectDisposedException occurred
  Message=Cannot access a disposed object.
Object name: 'FileCodeModel'.
Run Code Online (Sandbox Code Playgroud)

为了调试这个,我运行了另一个Visual Studios实例和"Debug-> Attach to Process"到Visual studio的实例,其中显示了异常.

我能够在启动附加到进程的新实例中捕获异常.我遇到以下异常:

System.ObjectDisposedException occurred
  Message=Cannot access a disposed object.
Object name: 'FileCodeModel'.
  Source=Microsoft.VisualStudio.CSharp.Services.Language
  ObjectName=FileCodeModel
  StackTrace:
       at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CFileCodeModel.GetCompilation(Boolean fBlockForParses)
       at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CPartialTypeCollection.EnumerateParts()
       at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CPartialTypeCollection.get_Count()
       at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CSlowSnapshot..ctor(CodeElements collection)
       at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CPartialTypeCollection.CreateSnapshot()
       at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CCollectionBase.GetEnumerator()
       at EnvDTE.CodeElements.GetEnumerator()
       at MS.Internal.VSSymbols.SymbolProvider.GetProperties(String fullName, Boolean isTypeDefinition, Boolean useCodeModel)
       at Microsoft.Xaml.Symbols.IXamlSymbols.GetProperties(String typeName, Boolean isTypeDefinition, Boolean useCodeModel)
       at MS.Internal.Design.Markup.HostedType.BuildProperties(Boolean useCodeModel)
  InnerException: 
Run Code Online (Sandbox Code Playgroud)

任何人都会在你的XAML中遇到这个异常,你会怎么做才能修复它.

debugging wpf xaml exception visual-studio-2010

16
推荐指数
1
解决办法
3428
查看次数

如何从Node.js中的ajax帖子返回成功

我有这样的功能:

exports.saveAction = function (req, res) {
    var conn = mysql.createConnection({
        host     : nconf.get("database:host"),
        //port: 3306,
        user     : nconf.get("database:username"),
        password : nconf.get("database:password"),
        database : nconf.get("database:database"),
        multipleStatements: true,
        //ssl: 'Amazon RDS'
    });
    var action = req.body;   
    conn.query('UPDATE actions SET ? WHERE Id = ?', 
                  [action, action.Id], function (err, result) {
        conn.end();
        if (err) throw err;
        res.writeHead(200, { "Content-Type": "application/json" });
        res.end("Updated Successfully");
    });
};
Run Code Online (Sandbox Code Playgroud)

我返回"200",但它总是返回如下所示的错误子句:

$.ajax({
    url: "/api/action/SaveAction",
    type: "PUT",
    data: ko.toJSON(self.stripDownObj()),
    datatype: "json",
    contentType: "application/json; charset=utf-8",
    success: function (result) { …
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery node.js express

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

具有SPA架构的ValidateAntiForgeryToken

我正在尝试设置注册和登录Hot Towel SPA应用程序.我已经基于asp.net单页面应用程序模板创建了SimpleMembershipFilters和ValidateHttpAntiForgeryTokenAttribute .

你怎么得到的

 @Html.AntiForgeryToken()
Run Code Online (Sandbox Code Playgroud)

代码以Durandal SPA模式工作.

目前我有一个register.html

<section>
    <h2 data-bind="text: title"></h2>

    <label>Firstname:</label><input data-bind="value: firstName" type="text"  />
    <label>Lastname:</label><input data-bind="value: lastName" type="text"  />
    <label>Email:</label><input data-bind="value: emailAddress" type="text"  />
    <label>Company:</label><input data-bind="value: company" type="text"  />
    <br />
    <label>Password:</label><input data-bind="value: password1" type="password" />
    <label>Re-Enter Password:</label><input data-bind="value: password2" type="password" />
    <input type="button" value="Register" data-bind="click: registerUser" class="btn" />
</section>
Run Code Online (Sandbox Code Playgroud)

register.js:

define(['services/logger'], function (logger) {
    var vm = {
        activate: activate,
        title: 'Register',
        firstName: ko.observable(),
        lastName: ko.observable(),
        emailAddress: ko.observable(),
        company: ko.observable(),
        password1: …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc-4 knockout.js single-page-application durandal hottowel

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

内联CKEditor与knockoutjs集成

所以我试图将CKEditor的内联编辑与Knockout.js集成.我能够成功加载CKEditor和knockout.js.

我似乎无法获得ko.observable更新属性:

<script type="text/javascript">

    var viewModel = function () {
        var self = this;
        self.editorText = ko.observable('ABC');
        self.testNewValue = function () {
            console.log(this.editorText());
        };
    }

    ko.applyBindings(new viewModel());
</script>
Run Code Online (Sandbox Code Playgroud)

这是html:

<div id="editable" contenteditable="true" data-bind="html: editorText">
</div>
<div>
    <input type="button" data-bind="click: testNewValue" value="test" />
</div>
Run Code Online (Sandbox Code Playgroud)

无论您是否更新,console.log结果始终显示"ABC".注意:我也试过了data-bind="text: editorText"

jquery ckeditor knockout.js

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

未捕获的SyntaxError:实时但不是本地服务器上的意外令牌B.

所以我正在制作一些ajax帖子,它似乎在localhost上正常工作,但是当我将它发布到amazon上的ec2服务器时,我得到Uncaught SyntaxError:意外的令牌B.这似乎指向JSON解析失败.完全相同的数据库,相同的浏览器和相同的方法被调用.为什么它可以在本地而不是服务器上运行.

$.ajax({
                url: '@Url.Action("Action")',
                type: "POST",
                data: ko.toJSON(viewModel),
                dataType: "json",
                contentType: "application/json; charset:utf-8",
                success: function (result) {

                },
                error: function (xhr, textStatus, errorThrown) {
                    var errorData = $.parseJSON(xhr.responseText);
                    var errorMessages = [];

                    for (var key in errorData)
                    {
                        errorMessages.push(errorData[key]);
                    }
                    toastr.error(errorMessages.join("<br />"), 'Uh oh');
                }
            });
Run Code Online (Sandbox Code Playgroud)

这是服务器端的基本布局:

[HttpPost]
        public JsonResult Action(ViewModel model)
        {
            try
            {

                Response.StatusCode = (int)HttpStatusCode.OK;
                return Json("Successfull");
            }
            catch (Exception ex)
            {
                logger.Log(LogLevel.Error, string.Format("{0} \n {1}", ex.Message, ex.StackTrace));
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                List<string> errors = new List<string>(); …
Run Code Online (Sandbox Code Playgroud)

jquery json amazon-ec2 asp.net-mvc-3 knockout.js

5
推荐指数
2
解决办法
5388
查看次数

knockout.js订阅没有被第一组调用

我有一个带有observable的简单模型类.我只是想订阅它的集合.这是我的代码:

var dto = function (data) {
    var self = this;
    self.Value1 = ko.observable(data.Value1);
    self.Value1.subscribe(function(){
         console.log('here');
    });   
};
Run Code Online (Sandbox Code Playgroud)

首次设置Value1时,不会调用console.log(即ko.observable(data.Value1)

如何设置subribe函数在初始和更改时都会发生.

javascript knockout.js knockout-3.0

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

带有多个手柄和背景颜色的滑块内容

我正在尝试使用Jquery UI滑块,我可以在其中有多个句柄:

$(function () {
        var handlers = [25, 50, 75];
        $("#slider").slider({
            min: 0,
            max: 100,
            values: handlers,
            slide: function (evt, ui) {
                for (var i = 0, l = ui.values.length; i < l; i++) {
                    if (i !== l - 1 && ui.values[i] > ui.values[i + 1]) {
                        return false;
                    }
                    else if (i === 0 && ui.values[i] < ui.values[i - 1]) {
                        return false;
                    }
                }
            }
        });
    });
Run Code Online (Sandbox Code Playgroud)

请注意,一个处理程序不能重叠,我需要在加载时动态设置处理程序,并在更改时保存处理程序位置.

我想要完成的事情是将处理程序之间的ui内容着色为不同的颜色.我附上了一张图片.

滑块

如果可能的话请提供建议.

jquery jquery-ui jquery-ui-slider

3
推荐指数
1
解决办法
5504
查看次数

避免使用AspNetUsers,AspNetRoles和AspNetUserRoles的"鉴别器"

我正在扩展IdentityUser,IdentityUserRole并且IdentityRole像这样:

public class ApplicationUser : IdentityUser
{
    public string FullName { get; set; }

    public virtual ICollection<ApplicationIdentityUserRole> Roles { get; } = new List<ApplicationIdentityUserRole>();
}

public class ApplicationIdentityUserRole : IdentityUserRole<string>
{
    public virtual ApplicationUser User { get; set; }
    public virtual ApplicationRole Role { get; set; }
}

public class ApplicationRole : IdentityRole
    {
        public virtual ICollection<ApplicationIdentityUserRole> Roles { get; } = new List<ApplicationIdentityUserRole>();
    }
Run Code Online (Sandbox Code Playgroud)

并配置如下:

public class SmartAccountingSetUpContext : IdentityDbContext<ApplicationUser>
{
    public SmartAccountingSetUpContext(DbContextOptions<SmartAccountingSetUpContext> …
Run Code Online (Sandbox Code Playgroud)

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

3
推荐指数
1
解决办法
1285
查看次数

AWS CodeDeploy :bucket 选项不得包含正斜杠 (/)

我正在从 aws-cli 开始部署:

"C:\Program Files\Amazon\AWSCLI\bin\aws.exe" deploy create-deployment --application-name App.Web --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name Development-Staging-UAT --region us-west-2 --description "App.Web" --s3-location bucket=app-artifacts/development,bundleType=zip,key=Publish.zip
Run Code Online (Sandbox Code Playgroud)

这确实启动了部署,但在 DownloadBundle 部分以错误结束:

:bucket option must not contain a forward-slash (/) 
Run Code Online (Sandbox Code Playgroud)

修订位置 s3://app-artifacts/development/Publish.zip

我究竟做错了什么?

aws-cli aws-code-deploy

3
推荐指数
1
解决办法
1234
查看次数

更新EndDate会导致"无效数据已用于更新列表项"

这是完整的错误:

Invalid data has been used to update the list item. The field you are trying to update may be read only.
Run Code Online (Sandbox Code Playgroud)

我基本上尝试更新Sharepoint中的日历事件.

首先,我得到以下内容.

ClientContext clientContext = new ClientContext(deptUrl);
Web web = clientContext.Web;
List list = web.Lists.GetByTitle(deptCal);
clientContext.Load(list);

CamlQuery query = new CamlQuery();
query.ViewXml = "<View><Query><Where><IsNull><FieldRef Name='EndDate' /></IsNull></Where></Query><RowLimit>1</RowLimit></View>";

ListItemCollection allEventIds = list.GetItems(query);

clientContext.Load(allEventIds, 
items => items.Include(
     item => item["EventID"],
     item => item["EventDate"],
     item => item["EndDate"]
));

clientContext.ExecuteQuery();
Run Code Online (Sandbox Code Playgroud)

接下来循环:

foreach (var item in allEventIds)
{
   Console.Write("EventId: {0} StartDate: {1}\n", item.FieldValues["EventID"], item.FieldValues["EventDate"]); …
Run Code Online (Sandbox Code Playgroud)

sharepoint sharepoint-2010

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