我正在使用Objective C编写Xcode中的计算器进行学习(我是初学者.).这是我正在使用的代码(计算NSString).
- (IBAction)resultButtonPressed:(id)sender {
NSExpression *expression = [NSExpression expressionWithFormat:label_result.text];
label_result.text = [NSString stringWithFormat:@"%@", [expression expressionValueWithObject:nil context:nil]];
}
Run Code Online (Sandbox Code Playgroud)
问题是,只要用户键入"不可计算"的内容,如"6(5 + 1)"而不是"6*(5 + 1)",程序就会崩溃并且我得到这个:
2014-11-01 02:36:10.577 The Calculator[1515:575020] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "6(5+1) == 1"'
*** First throw call stack:
(0x18672de48 0x196e280e4 0x18753ad98 0x187538e2c 0x18764b128 0x18764b0c4 0x100062244 0x18af110f8 0x18aefa22c 0x18af10a94 0x18af10720 0x18af09c74 0x18aedd38c 0x18b17c1b4 0x18aedb8f4 0x1866e60e8 0x1866e538c 0x1866e343c 0x1866111f4 0x18f7a75a4 0x18af42784 0x10006286c 0x197496a08)
libc++abi.dylib: terminating with uncaught exception of type …Run Code Online (Sandbox Code Playgroud) 插件,C#,Microsoft Dynamics CRM Online
我想将一条记录(让我们称之为"sampleRecord")添加到一个实体集合(让我们称之为"sampleCollection"),但不知怎的,我无法使它工作.我在互联网上找到了这个解决方案,但是当我通过ITracingService检查总记录数时,它仍然是0.
到目前为止我的解
EntityCollection sampleCollection = new EntityCollection();
sampleCollection.Entities.Add(sampleRecord);
Run Code Online (Sandbox Code Playgroud)
这就是我检查总记录数的方式:
tracingService.Trace("total record count: " + sampleCollection.TotalRecordCount.ToString());
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助!
c# plugins microsoft-dynamics dynamics-crm dynamics-crm-online
我正在尝试为Microsoft Dynamics CRM Online中的电子邮件实体编写插件.让我们说它叫做"Sample_PlugIn".
我希望插件检索电子邮件的发件人,并将他/她的电子邮件地址写入电子邮件的字段(new_samplefield).
插件也做了一些其他的事情(并且它都在工作),但这部分代码是制造问题的部分.(我的组织服务参考称为"服务".)
try
{
Entity email = (Entity)context.InputParameters["Target"];
EntityCollection fromCollection = (EntityCollection)email.Attributes["from"];
if (fromCollection != null && fromCollection.Entities.Count > 0)
{
Entity sender = fromCollection[0];
email["new_samplefield"] = (string)sender.Attributes["internalemailaddress"];
}
service.Update(email);
}
Run Code Online (Sandbox Code Playgroud)
每次执行插件时,都会收到此错误:
插件的意外异常(Execute):Sample_PlugIn.Sample_PlugIn:System.Collections.Generic.KeyNotFoundException:字典中不存在给定的键.
如果有人能帮助我会很棒 - 非常感谢!
c# plugins dynamics-crm dynamics-crm-online dynamics-crm-2016