我有几个在Window.Resources中声明的图标.它们在第一次出现时显示正常(例如:单击菜单,MenuItem图标有效),但在显示另一个菜单(例如:上下文菜单)后,原始图标消失且不返回.好像第一次使用该图标的最后一个元素就是保留它.
<Window.Resources>
<Image x:Key="Chart_16"
Source="pack://application:,,,/Resources/images/chart_16.png" />
...
<Window.Resources>
<MenuItem Header="Summary"
Command="loc:AppCommands.ShowSummary"
Icon="{StaticResource Chart_16}" />
Run Code Online (Sandbox Code Playgroud)
我已经尝试将其保存为24位PNG,隔行扫描24位PNG和8位PNG,但同样的事情发生了.它不仅仅是一个,在不止一个地方使用的每个图标都是这样的.
我有一个将返回一行的查询.有什么办法可以在表格排序时找到我要查询的行的行索引吗?
我已经尝试rowid了,但当我期待第7行时,我得到了#582.
例如:
CategoryID Name
I9GDS720K4 CatA
LPQTOR25XR CatB
EOQ215FT5_ CatC
K2OCS31WTM CatD
JV5FIYY4XC CatE
--> C_L7761O2U CatF <-- I want this row (#5)
OU3XC6T19K CatG
L9YKCYAYMG CatH
XKWMQ7HREG CatI
Run Code Online (Sandbox Code Playgroud)
我尝试过rowid意外的结果:
SELECT rowid FROM Categories WHERE CategoryID = 'C_L7761O2U ORDER BY Name
Run Code Online (Sandbox Code Playgroud)
编辑:我也尝试过J Cooper的建议(如下),但行数不正确.
using (var cmd = conn.CreateCommand()) {
cmd.CommandText = string.Format(@"SELECT (SELECT COUNT(*) FROM Recipes AS t2 WHERE t2.RecipeID <= t1.RecipeID) AS row_Num
FROM Recipes AS t1
WHERE RecipeID = 'FB3XSAXRWD'
ORDER BY Name";
cmd.Parameters.AddWithValue("@recipeId", …Run Code Online (Sandbox Code Playgroud) 我试图让ActiveDirectory和标准表单登录工作,但有一件事阻止了我.我无法获得当前Windows用户的名称.我最接近的是var i = WindowsIdentity.GetCurrent();,但这给了我IIS应用程序池用户的名字.我在IIS中启用了匿名身份验证,表单身份验证和Windows身份验证.我可以从AD加载用户,所以我假设我的web.config设置正确.
编辑:这是我的web.config(使用Facade提供程序):
<membership defaultProvider="HybridMembershipProvider">
<providers>
<clear />
<add name="HybridMembershipProvider" type="MyApp.Data.HybridMembershipProvider" AspNetProviderName="AspNetSqlMembershipProvider" ActiveDirectoryProviderName="ADMembershipProvider" />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MyAppConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
<add name="ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADConnectionString"
attributeMapUsername="sAMAccountName" enableSearchMethods="true" attributeMapEmail="mail"/>
</providers>
</membership>
Run Code Online (Sandbox Code Playgroud)
编辑2:这是我的IIS安全设置.

asp.net forms-authentication active-directory windows-authentication
我知道如果我不使用名为_id的字段作为我在Android中的主键,那些像CursorAdapter这样的东西将不起作用,但_id列是否需要是一个自动增量int?我可以使用Guid作为键,只要它被称为_id,并且CursorAdapter仍然有效吗?
我正在尝试让Community.Csharp使用Windows Phone,我尝试使用http://wp7sqlite.codeplex.com/中的版本并使用WINDOWS_PHONE标志编译主干,但是当我运行应用程序时手机我在尝试执行任何查询时遇到错误(但在打开数据库时没有;只在查询时):"无法打开数据库文件"
_conn = new SqliteConnection("Version=3,uri=file:recipes.sqlite");
_conn.Open();
cmd.CommandText = "SELECT * FROM recipes";
SqliteDataReader reader = cmd.ExecuteReader();
Run Code Online (Sandbox Code Playgroud)
有趣的是,我使用以下内容来检查是否存在表,并且不会抛出任何异常:
cmd.CommandText = "SELECT * FROM sqlite_master WHERE name='" + tableName + "'";
SqliteDataReader rdr = cmd.ExecuteReader();
exists = rdr.Read();
rdr.Close();
Run Code Online (Sandbox Code Playgroud)
我有一个使用SQLite的Windows应用程序,所以如果我可以使用SQLite而不是Sterling DB或其他东西,那将节省大量时间.我现在遇到的问题是,一旦我打开数据库并关闭它,我就无法重新打开它.
我尝试在http://landlordscores.co.uk/account/login.aspx上使用Facebook身份验证,但在使用Facebook登录后,回调页面显示"无效的签名请求.(无效签名.)".应用程序ID和密码是正确的,似乎没有记录其他信息.每次我尝试使用Facebook登录时都会发生这种情况.
编辑: 为了进行调用,我使用了几乎所有的代码作为示例.在标记中:
<iframe src="<%= this.RegistrationUrl %>"
scrolling="auto"
frameborder="no"
style="border:none"
allowTransparency="true"
width="100%"
height="500">
</iframe>
Run Code Online (Sandbox Code Playgroud)
在代码隐藏中:
public string RegistrationUrl {
get
{
var url = string.Format(
"http://www.facebook.com/plugins/registration.php?client_id={0}&redirect_uri={1}&fields={2}",
FacebookApplication.Current.AppId,
HttpUtility.UrlEncode(AppBLL.GetAbsoluteURL("~/Account/fbregcallback.aspx")),
HttpUtility.UrlEncode("[{\"name\":\"name\"},{\"name\":\"email\"},{\"name\":\"location\"},{\"name\":\"password\",\"view\":\"not_prefilled\"},{\"name\":\"captcha\"}]")); this.RegisterUser.ContinueDestinationPageUrl = this.Request.QueryString["ReturnUrl"];
this.hdnPassLength.Value = Membership.MinRequiredPasswordLength.ToString();
HttpUtility.UrlEncode("[{\"name\":\"name\"},{\"name\":\"email\"},{\"name\":\"location\"},{\"name\":\"password\",\"view\":\"not_prefilled\"},{\"name\":\"captcha\"}]"));
this.hdnPassLength.Value = Membership.MinRequiredPasswordLength.ToString();
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个VB.NET类,我在asmx文件中通过XML序列化.我已经在序列化中添加了我想要忽略的数据库的属性,但它仍然被返回.我也有<DataContract()>我的类的DataMember属性和所有应该序列化的属性的属性.我的财产声明是:
<ScriptIgnore()> _
<IgnoreDataMember()> _
Public Property Address() As SomeObject
Run Code Online (Sandbox Code Playgroud) 我正在尝试在.NET中调整图像大小,但在调整大小的图像周围会出现一个模糊的黑色边框.我发现了一篇帖子http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/cf765094-c8c1-4991-a1f3-cecdbd07ee15/,其中有人说目标矩形大于画布工作,但这对我不起作用.它的顶部和左边界都是riid,但右边和底部仍然存在,并且是一个完整的1px厚的黑色.
我错过了什么吗?我的代码如下.
Image image = ... // this is a valid image loaded from the source
Rectangle srcRectangle = new Rectangle(0,0,width, height);
Size croppedFullSize = new Size(width+3,height+3);
Rectangle destRect = new Rectangle(new Point(-1,-1), croppedFullSize);
using(Bitmap newImage = new Bitmap(croppedFullSize.Width, croppedFullSize.Height, format))
using(Graphics Canvas = Graphics.FromImage(newImage)) {
Canvas.SmoothingMode = SmoothingMode.AntiAlias;
Canvas.InterpolationMode = InterpolationMode.HighQualityBicubic;
Canvas.PixelOffsetMode = PixelOffsetMode.HighQuality;
Canvas.FillRectangle(Brushes.Transparent, destRect);
Canvas.DrawImage(image, destRect, srcRectangle, GraphicsUnit.Pixel);
newImage.Save(filename, image.RawFormat);
}
Run Code Online (Sandbox Code Playgroud) 我试图使用ASP.NET 4和VB.NET从ViewState加载一个List,这有点困难.当我尝试使用以下方法检索集合时:
Public Property ItemsForImport As List(Of ImportItem)
Get
Return IIf(ViewState("ItemsForImport") Is Nothing, New List(Of ImportItem), CType(ViewState("ItemsForImport"), List(Of ImportItem)))
End Get
Set(value As List(Of ImportItem))
ViewState("ItemsForImport") = value
End Set
End Property
Run Code Online (Sandbox Code Playgroud)
我得到了例外:
[A]System.Collections.Generic.List`1[ImportItem] cannot be cast to [B]System.Collections.Generic.List`1[ImportItem].
Type A originates from 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'.
Type B originates from 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'.
Run Code Online (Sandbox Code Playgroud)
调试显示该集合不为null并包含2个项目.该类只定义一次,我已经清理了我的临时文件C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
一般来说,我有时会在调试时进行快速更改时看到这个(我假设每个人都这样做),但是经过几次刷新之后.有什么我想念的吗?
我有一个新的 .NET Core 3.1 应用程序,并且正在努力解决中间件的概念。通过阅读,似乎包含不同中间件的顺序很重要。我目前有几个似乎无法解决的问题:
这就是我引导应用程序的方式。感觉就像有什么东西覆盖了设置:
public void ConfigureServices(IServiceCollection services)
{
services.Configure<DataProtectionTokenProviderOptions>(options =>
options.TokenLifespan = TimeSpan.FromDays(2));
services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromMinutes(30);
});
services.AddControllersWithViews();
services.AddTransient<IUserStore<User>, UserStore>();
services.AddTransient<IRoleStore<IdentityRole>, RoleStore>();
services.AddRazorPages();
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.LoginPath = new PathString("/login");
options.AccessDeniedPath = new PathString("/error/denied");
options.LogoutPath = new PathString("/log-off");
options.ExpireTimeSpan = TimeSpan.FromDays(60);
options.SlidingExpiration = true;
options.Cookie.HttpOnly = true;
options.Cookie.Name = "MyCookie";
options.ReturnUrlParameter = …Run Code Online (Sandbox Code Playgroud) asp.net ×5
sqlite ×3
.net ×2
c# ×2
vb.net ×2
.net-core ×1
android ×1
api ×1
asmx ×1
asp.net-core ×1
compilation ×1
cursor ×1
drawing2d ×1
facebook ×1
graphics ×1
icons ×1
menuitem ×1
primary-key ×1
sql ×1
sql-order-by ×1
viewstate ×1
web-services ×1
wpf ×1