小编elr*_*anu的帖子

简单的Windows窗体/ WPF应用程序是否适用于Windows 8平板电脑?

我正在开发一个需要在Windows 7,Windows 8和Windows 8 Tablet上运行的C#.NET业务应用程序.

  1. "简单"的Windows窗体应用程序是否适用于Windows 8桌面和平板电脑?
  2. 有Windows 8平板电脑模拟器吗?
  3. 还有其他选择吗?

.net c# windows windows-8

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

建立代码合同?

我有以下方法:

private void DoSomething(CoolClass coolClass)
{
    if (coolClass == null)
    {
        throw new ArgumentNullException("coolClass");
    }
    coolClass.Name = "Pepe";
}
Run Code Online (Sandbox Code Playgroud)

使用代码契约,我们可以这样写:

private void DoSomething(CoolClass coolClass)
{
    Contract.Requires<ArgumentNullException>(coolClass != null, "IS NULLL!");
    coolClass.Name = "Pepe";
}
Run Code Online (Sandbox Code Playgroud)

第二种方法更短更简单.我遇到的问题是,当你构建它时,在运行时它不会抛出异常,它显示了这个:

说明:必须使用代码契约二进制重写器(CCRewrite)重写程序集(可能是"CodeContractsTest"),因为它正在调用Contract.Requires并且定义了CONTRACTS_FULL符号.从项目中删除CONTRACTS_FULL符号的任何显式定义并重建.CCRewrite可以从http://go.microsoft.com/fwlink/?LinkID=169180下载.安装重写器后,可以从"代码约定"窗格上项目的"属性"页面在Visual Studio中启用它.确保启用"执行运行时合同检查",这将定义CONTRACTS_FULL.

除非使用VS,否则请从此处下载.net的CodeContracts .

然后检查项目中的"运行时检查",以便在运行时构建它时,抛出异常.

我们的应用程序是使用Jenkins和PowerShell脚本构建的.有没有办法检查运行时并抛出异常,使用简单的命令或属性,或者简单的东西?

c# code-contracts

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

远程服务器返回错误:(401)未经授权.Twitter oAuth

我正在尝试使用twitterizer与twitter oAuth合作,但我无法做到.

我收到以下错误:

The remote server returned an error: (401) Unauthorized.

当我的回调网址是本地主机时.

如果我的回调网址是oob,针对引脚流程它可以正常工作.

这是我的代码:

 public ActionResult LogOn(string returnUrl, bool? perm)
    {
        string consumerKeyTw = @"UF3F72XqfGShQs7juKMApA";
        string consumerSecretTW = "secret";
        OAuthTokenResponse requestToken = OAuthUtility.GetRequestToken(consumerKeyTw, consumerSecretTW, "http://localhost:58892/Twitterr/OAuth");

        // Direct or instruct the user to the following address:
        Uri authorizationUri = OAuthUtility.BuildAuthorizationUri(requestToken.Token);

        return new RedirectResult(authorizationUri.ToString(), false);
    }
Run Code Online (Sandbox Code Playgroud)

我在设置回调网址时从未获得令牌.在twitter上我注册了我的回调url localhost.

我错过了什么吗?

有什么想法吗?

c# oauth twitterizer asp.net-mvc-3

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

ASP.NET MVC 3更快的本地化?

有什么方法可以加速使用剃须刀在ASp.Net mvc3上进行字符串本地化?不要说我在我的.cshtml"Hello World"上写,然后我想将"Hello world"发送到资源,只需点击几下就可以通过自动Id和重构字符串来调用资源.像http://resourcerefactoring.codeplex一样的东西,但VS 2010和剃须刀.

而且免费!

谢谢!

visual-studio-2010 razor asp.net-mvc-3

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

无法加载文件或程序集"AutoMapper"或其依赖项之一

我部署时遇到这个问题,我真的不知道如何解决它.任何的想法?

Server Error in '/' Application.
Could not load file or assembly 'AutoMapper' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.BadImageFormatException: Could not load file or assembly 'AutoMapper' or one of its …
Run Code Online (Sandbox Code Playgroud)

.net iis automapper asp.net-mvc-3

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

回调函数中的javascript类变量作用域

可能重复:
在Javascript中,为什么"this"运算符不一致?

我有以下课程:

function Chat(some, nick, url) {
    this.socket = null;
    this.Nickname = nick;
    this.Url = url;

    this.Connect = function () {
        socket = io.connect(this.Url);
        socket.on('connect', function (data) {
            var p = this.Nickname; //this.Nickname is undefined why? 
            // how can I acess to the Nickname variable or function?
        }
    };
}
Run Code Online (Sandbox Code Playgroud)

如何从connect回调函数访问实例变量或函数?

javascript node.js

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

在紧凑和完整的.net框架之间切换编译?

有谁知道如何在visual studio上切换库项目的编译,所以我可以编译为紧凑的框架和完整的.Net框架?

.net c# compact-framework visual-studio-2008 visual-studio

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

MongoDB设计 - 标签

我是MongoDB的新手.我有一个关于MongoDB性能的设计问题.假设我有类电影有两个属性,名称和导演.另外我想标记这个电影类.最好为这个类添加一个新的strings []属性,或者创建一个新的类MovieTags?我知道我会查询这个标签很多,因为我会在UI上使用自动完成功能.对于这个自动完成功能,我只需要标签,而不是Movie对象.什么选择更好?添加一个strings []的属性或引用MovieTags的集合?考虑性能......当然,在这两种情况下都会进行索引编制.

我应该使用MapReduce吗?如果我使用一个embebed string []对象,只为自动完成功能选择标签?怎么样?

谢谢!

.net mongodb norm

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

使用Recaptcha对Action进行单元测试

我如何测试控制器的以下动作:

 public ActionResult Edit(User usr)
    {
        if (!Microsoft.Web.Helpers.ReCaptcha.Validate(ConfigurationManager.AppSettings["reCaptchaPrivate"].ToString()))
        {
            ModelState.AddModelError("reCaptcha", PPRR.App_LocalResources.Global.ErrorFillReCaptcha);
            return PartialView("Wrong", usr);
        }
        if (ModelState.IsValid)
        {code..... }}
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc unit-testing asp.net-mvc-3

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

Asp.Net MVC上的HttpRequestValidationexception

我收到一条带有此错误消息的HttpRequestValidationexception:

"从客户端检测到一个潜在危险的Request.Form值".

但我在属性上有AllowHtml,我收到了错误.问题是,稍后在我的代码中我得到以下属性以巫婆格式知道我将显示我的观点ControllerContext.HttpContext.Request.Params.AllKeys.Contains("format").在这个"Param Getter"中,我收到了错误.

假设我的代码类似于以下内容:

public class House
{
    [AllowHtml]
    public string Text { get; set; }
    public string Name { get; set; }
}

[HttpPost, ValidateAntiForgeryToken]
public ActionResult CreateTopic(House h)
{
 //business code
 if(ControllerContext.HttpContext.Request.Params.AllKeys.Contains("format"))
 {
    Return view;
 }
 }
Run Code Online (Sandbox Code Playgroud)

我怎么解决这个问题?我已经尝试ValidateInput(false)了控制器动作方法的属性.任何的想法?

asp.net asp.net-mvc-3

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