我正在使用Microsoft Visual Studio express 2012 for web编写MVC4网站.每当我在程序包管理器控制台中运行"Update-Database"时,都会发生以下异常:
To call this method, the "Membership.Provider" property must be an instance of "ExtendedMembershipProvider".
这是我的种子方法:
protected override void Seed(GNSystem.Models.DataContext context)
{
context.Forums.AddOrUpdate(
new Forum { ForumName = "Hello" },
new Forum { ForumName = "World" },
new Forum { ForumName = "!" }
);
context.UserProfiles.Add(new UserAccount { UserName = "Gilad", EMail = "gilad.doom@gmail.com" });
WebSecurity.CreateUserAndAccount("Gilad", "123456");
WebSecurity.Login("Gilad", "123456");
context.Threads.AddOrUpdate(
new Thread { Subject = "FirstThread", Content = "Awesome Content", ForumID = 1, UserID = …Run Code Online (Sandbox Code Playgroud) 我总是找到非常复杂的方法来序列化所有类型的对象,列表和谁知道,但我似乎无法找到序列化数组的简单方法.
(我发现了一个,但它将数组序列化为二进制文件,我需要能够在任何常规文本编辑器中编辑序列化文件[这是一个语言文件,我需要给我的同事复制,这样他们就可以了将文件翻译成其他语言/])
当应用程序区域设置设置为:he时,以下自动生成的代码将引发异常:
undefined method `map' for "translation missing: he.date.order":String
<%= f.date_select :birthday %>
Run Code Online (Sandbox Code Playgroud)
我仔细检查过,不仅希伯来语和英语的语言环境相同(按键),英语语言环境文件不包括en.date.order.
这个例外可以从哪里来?
我使用的是Ruby 2带Rails 4.
编辑: 解决方案:
he:
date: #Throws an exception otherwise.
order:
- "year"
- "month"
- "day"
Run Code Online (Sandbox Code Playgroud) 我使用了以下几个C预处理器宏:
#define TAKE4(a1, a2, a3, a4, ...) a1, a2, a3, a4
#define FILL_PARAMS(...) TAKE4(__VA_ARGS__, 0, 0, 0, 0)
Run Code Online (Sandbox Code Playgroud)
当FILL_PARAMS使用1,2或3个参数调用时,后面的(未指定的)会按预期变为0,但是当不给出参数时会出现错误.
有没有办法添加对无参数的支持?
澄清:
目前支持以下用途:
FILL_PARAMS(1) // => 1, 0, 0, 0
FILL_PARAMS(1, 2) // => 1, 2, 0, 0
FILL_PARAMS(1, 2, 3) // => 1, 2, 3, 0
Run Code Online (Sandbox Code Playgroud)
我想添加对以下边缘情况的支持:
FILL_PARAMS() // => 0, 0, 0, 0
Run Code Online (Sandbox Code Playgroud)
欢迎提供帮助.
我建立了一个小程序来计算15个或更少的平均数.有15个文本框,每个文本框的默认值为"0".程序知道获取所有类型数字的总和,并将其除以不返回"0"的文本框的数量.但是如果用户错误地删除了其中一个文本框中的'0'之一..运行时错误.
最初我通过写这个" if语句 "15次(每个文本框一个)来解决这个问题:
if (t1.Text == "") { tr1 = 0; }
else
{
tr1 = Double.Parse(t1.Text);
}
Run Code Online (Sandbox Code Playgroud)
此代码检查文本框中是否有东西(例如,名为t1),如果为true,则程序给出双 'tr1'(不要与't1'混淆),值为'0'如果假,代码给出了双 'TR1"T1"的文字.
我不得不写'如果'15次.我想知道我是否可以用数组和for循环编写相同的代码,以及如何?
这是整个代码(抱歉var名称与var的使用不相似.):
private void goyouidiot_Click(object sender, EventArgs e)
{
double tr1;
double tr2;
double tr3;
double tr4;
double tr5;
double tr6;
double tr7;
double tr8;
double tr9;
double tr10;
double tr11;
double tr12;
double tr13;
double tr14;
double tr15;
if (t1.Text == "") { tr1 = 0; }
else
{
tr1 = Double.Parse(t1.Text);
}
if (t2.Text …Run Code Online (Sandbox Code Playgroud) 我在WPF中有一个使用ScrollViewr的应用程序,我想将它移植到WinForms,是否有一个等效的WinForms控件?
原因:
WPF程序很慢,我似乎无法学习如何正确渲染程序(GameOfLife).码:
<ScrollViewer Name="displayPlaceHolder" HorizontalScrollBarVisibility="Auto">
<Canvas Name="display" MouseMove="display_MouseMove" MouseDown="display_MouseDown" Cursor="Cross" KeyDown="global_KeyDown" Focusable="True" />
</ScrollViewer>
Run Code Online (Sandbox Code Playgroud) 我可以将内容项目引用到非XNA项目(MonoGame,如果它很重要)吗?
在部署到AppHarbor时,AppHarbor给了我以下编译输出:
Microsoft (R) ASP.NET Compilation Tool version 4.0.30319.17929
Utility to precompile an ASP.NET application
Copyright (C) Microsoft Corporation. All rights reserved.
D:\temp\cprt3dr0.2g3\output\_PublishedWebsites\WebMatrixWebsite\gnsystem\gnsystem\web.config(24): error ASPCONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
[ConfigurationErrorsException]: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not …Run Code Online (Sandbox Code Playgroud) 我注意到以下代码在语法上是正确的:
class Foo
bar = 3
end
Run Code Online (Sandbox Code Playgroud)
现在,我知道实例变量是由@和类变量访问的,@@但我无法弄清楚bar在这种情况下存储的位置或如何访问它.
我怎样才能找到bar范围?