我正在编写WCF服务,并希望公开一些自定义配置元素(例如Custom ConfigurationSection和ConnectionStringSettings),以便我可以修改服务的配置.
我的一个自定义配置元素继承自System.Configuration.ConfigurationElementCollection.当我尝试启动我的WCF服务时,我收到以下错误消息...
类型'System.Configuration.ConfigurationElementCollection'无法序列化.请考虑使用DataContractAttribute属性对其进行标记,并使用DataMemberAttribute属性标记要序列化的所有成员.
有没有办法为此类型实现DataContract?我有我的继承类标有[DataContract]属性.
wcf serialization datacontract datamember configurationelement
所以,我有一个项目,我需要在用户按下按钮时强制更改方向.我在github上创建了一个示例应用程序来演示这个问题.
@interface DefaultViewController () {
UIInterfaceOrientation _preferredOrientation;
}
Run Code Online (Sandbox Code Playgroud)
一些旋转处理位
- (BOOL)shouldAutorotate {
return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return _preferredOrientation;
}
Run Code Online (Sandbox Code Playgroud)
和切换
- (IBAction)toggleButtonPressed:(id)sender {
_preferredOrientation = UIInterfaceOrientationIsPortrait(_preferredOrientation)
? UIInterfaceOrientationLandscapeRight
: UIInterfaceOrientationPortrait;
[self forceOrientationChange];
}
- (void)forceOrientationChange
{
UIViewController *vc = [[UIViewController alloc] init];
[self presentViewController:vc animated:NO completion:nil];
[UIView animateWithDuration:.3 animations:^{
[vc dismissViewControllerAnimated:NO completion:nil];
} completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
因此,当您按下切换按钮时,这似乎工作正常,它会按预期更改方向.但是当我开始改变设备的实际方向时,就会出现问题.
重现问题的步骤:
结果是视图不会旋转到横向,但状态栏会旋转.

任何帮助将不胜感激!