我已经多次使用扩展方法,并没有遇到这个问题.任何人都有任何想法,为什么这会引发错误?
/// <summary>
/// Rounds the specified value.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="decimals">The decimals.</param>
/// <returns></returns>
public static decimal Round (this decimal value, int decimals)
{
return Math.Round(value, decimals);
}
Run Code Online (Sandbox Code Playgroud)
用法:
decimal newAmount = decimal.Parse("3.33333333333434343434");
this.rtbAmount.Text = newAmount.Round(3).ToString();
Run Code Online (Sandbox Code Playgroud)
newAmount.Round(3)抛出了编译器错误:
Error 1 Member 'decimal.Round(decimal)' cannot be accessed with an instance reference; qualify it with a type name instead
Run Code Online (Sandbox Code Playgroud) 我目前在SSRS报告中有一个Matrix.通常,矩阵将以纵向模式固定到标准页面,但是有时列的长度将超过页面.有没有办法让SSRS将报表呈现为PDF,此Matrix将自动调整大小并缩小其所有内容,即:字体,列宽以适合页面?我不想收缩SSRS报告中的所有对象来修复页面,只是缩小Matrix的宽度.
当我使用System.Net.Mail发送邮件时,似乎邮件不会立即发送.他们在到达我的收件箱之前需要一两分钟.一旦我退出应用程序,所有消息都会在几秒钟内收到.是否有某种邮件消息缓冲区设置可以强制SmtpClient立即发送消息?
public static void SendMessage(string smtpServer, string mailFrom, string mailFromDisplayName, string[] mailTo, string[] mailCc, string subject, string body)
{
try
{
string to = mailTo != null ? string.Join(",", mailTo) : null;
string cc = mailCc != null ? string.Join(",", mailCc) : null;
MailMessage mail = new MailMessage();
SmtpClient client = new SmtpClient(smtpServer);
mail.From = new MailAddress(mailFrom, mailFromDisplayName);
mail.To.Add(to);
if (cc != null)
{
mail.CC.Add(cc);
}
mail.Subject = subject;
mail.Body = body.Replace(Environment.NewLine, "<BR>");
mail.IsBodyHtml = true;
client.Send(mail);
}
catch (Exception …Run Code Online (Sandbox Code Playgroud) 我的问题是:CLLocationManager是否继续运行,而我的应用程序处于非活动状态?
要清除我的文本框,我在表单中使用以下代码:
foreach (Control c in this.Controls)
{
if (c is TextBox || c is RichTextBox)
{
c.Text = "";
}
}
Run Code Online (Sandbox Code Playgroud)
但现在我的文本框位于TabControl中.如何对文本框运行相同类型的检查,如果控件是文本框,则将值设置为"".我已经尝试过使用:
foreach(Control c in tabControl1.Controls)
Run Code Online (Sandbox Code Playgroud)
但这没效果.
以下代码仅适用于IIS中仅为我们网络上的本地用户启用Windows身份验证的情况.
using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain))
{
UserPrincipal up = UserPrincipal.FindByIdentity(ctx, userName);
return up;
}
Run Code Online (Sandbox Code Playgroud)
否则会抛出此异常:
[ArgumentException :(&(objectCategory = user)(objectClass = user)(|(userPrincipalName =)(distinguishedName =)(name =)))搜索过滤器无效.] System.DirectoryServices.ResultsEnumerator.MoveNext()+434305 System .DirectoryServices.SearchResultCollection.get_InnerList()+282 System.DirectoryServices.SearchResultCollection.get_Count()+ 9 System.DirectoryServices.AccountManagement.ADStoreCtx.FindPrincipalByIdentRefHelper(Type principalType,String urnScheme,String urnValue,DateTime referenceDate,Boolean useSidHistory)+1898 System. DirectoryServices.AccountManagement.ADStoreCtx.FindPrincipalByIdentRef(类型principalType,String urnScheme,String urnValue,DateTime referenceDate)+85 System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext context,Type principalType,Nullable`1 identityType,String identityValue,DateTime refDate)+ 211 System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext context,String identi)tyValue)+95 WebApplication1.Index.GetUserPrincipal(String userName)在C:\ Users\xxx\Documents\Visual Studio 2010\Projects\WebApplication1\WebApplication1\Index.aspx.cs:38 WebApplication1.Index.Page_Load(Object sender,EventArgs) e)在C:\ Users\xxx\Documents\Visual Studio 2010\Projects\WebApplication1\WebApplication1\Index.aspx.cs:19 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,Object o,Object t,EventArgs e) )+25 System.Web.UI.Control.LoadRecursive()+71 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+3064
是否有任何方法可以让这个用于获取本地用户UserPrincipal 而Windows和匿名身份验证都打开?
我从未使用过INotifyPropertyChanged,我正在考虑在新的应用程序中广泛使用它.
我的问题是,使用INotifyPropertyChanged接口以便为数据绑定控件以外的其他内容提供事件通知是否"合适"?
从在线的一些示例中可以看出,该接口广泛用于通知网格,例如数据更改时.我有各种各样的场景,我需要其他类通知其他类中的数据更改,我想知道你是否认为实现这个接口更清晰,并在setter上执行更改的调用,或者更确切地说是创建常规事件.
我已经创建了一个Outlook加载项,我正在使用XML功能区配置文件来指定一个新选项卡和按钮.该按钮加载到outlook中的新选项卡中.现在有时,基于用户我们希望能够隐藏或禁用这些按钮.通过Outlook Interop api禁用自定义选项卡上的菜单按钮的最简单方法是什么?
我的第一个猜测是,我需要在创建功能区后迭代一些命令栏集合,然后搜索我的菜单按钮,但我不确定这些集合在哪里.
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
this.ribbon = new MyRibbon();
// loop through tabs and ribbon items, look for my custom control, and enabled/disable specific buttons.
return this.ribbon;
}
Run Code Online (Sandbox Code Playgroud) 我有silverlight应用程序,并且出现此错误:
[Async_ExceptionOccurred]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=5.0.61118.00&File=System.dll&Key=Async_ExceptionOccurred INNER >System.ServiceModel.CommunicationException: [CrossDomainError]
Arguments: http://localhost/pthaba/SimpleWCF.svc
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=5.0.61118.00&File=System.ServiceModel.dll&Key=CrossDomainError ---> System.Security.SecurityException ---> System.Security.SecurityException: [Arg_SecurityException]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=5.0.61118.00&File=mscorlib.dll&Key=Arg_SecurityException
Run Code Online (Sandbox Code Playgroud)
我有WCF服务,并且可以在浏览器上正常工作。我在根站点(位于WCF服务所在的位置)中具有如下所示的clientacesspolicy.xml。
<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from …Run Code Online (Sandbox Code Playgroud) 在 ReportViewer 中使用默认导出按钮时,是否可以简单地提示用户打开导出的报告?我查看了 ReportExport 事件,尽管这会在导出发生之前触发。我唯一能想到的就是取消 ReportExport 并创建我自己的导出功能,尽管我希望我不需要这样做。导出发生后是否有任何我错过的事件?
c# ×6
.net ×2
winforms ×2
.net-4.0 ×1
asp.net ×1
c#-4.0 ×1
controls ×1
iis-7 ×1
iis-7.5 ×1
ios ×1
ipad ×1
iphone ×1
mailmessage ×1
objective-c ×1
outlook ×1
ribbon ×1
rounding ×1
silverlight ×1
smtp ×1
smtpclient ×1
ssrs-2008 ×1
ssrs-tablix ×1
tabcontrol ×1
wcf ×1