因为monotouch编译为本机代码,所以它有一些限制,例如不允许动态调用.
但我在.net中有很多类,我使用ChannelFactory动态来调用wcf服务:new ChannelFactory(myBinding,myEndpoint); 现在在monotouch中我应该使用slsvcutil来生成wcf代理类,但是slsvcutil会生成大量不必要的额外代码(巨大的),并且由于通过ClientBase类与WCF基础结构的高度耦合,使得消费者难以进行单元测试.
除了ChannelFactory之外还有更好的解决方案吗?我宁愿手动编写代码,也可以更好地控制如何调用服务,例如ChannelFactory.
==========
ChannelFactory<IMyContract> factory = new ChannelFactory<IMyContract>(binding, endpointAddress);
return factory.CreateChannel();
Run Code Online (Sandbox Code Playgroud)
// ==>它抛出异常:MonoTouch不支持动态代理代码生成.重写此方法或其调用方以返回特定的客户端代理实例
我使用Dotfuscator来保护我的应用程序免受逆向工程我加密了Windows应用程序中的dll文件,但我怎样才能在OSX/MonoTouch中执行此操作?
从ipa中提取dll,然后在windows中混淆dll,并将加密的dll重新打包到IPA中,然后将其发布到appstore?
有没有简单的解决方案?
在Xamarin Studio 5.0.1(build3)中.
我在编辑器中输入代码,当我输入时ENTER
,为什么缩进太长,{
符号没有与if
关键字对齐,并且int i = 3
没有与上面的行对齐?
这是对正在发生的事情的直观表示:
if (mUri == uri)
{
mImageView.Image = image;
int i=3
}
Run Code Online (Sandbox Code Playgroud)
xs perferences:behavior =>缩进模式:smart(也可尝试选项:none,自动)SourceCode /代码格式化:c#源代码/策略:已尝试以下选项:mono/visual studio/custom/tab width:4 .. .
相同的设置是Xamarin Studio 4.3都可以.
我也尝试卸载xs5.0并重新安装它,但没有解决.
任何新项目也会发生.
我使用scrollview来显示多页视图,它有10页以上.(scrollview.PageEnabled = TRUE)
scrollview中的每个页面都有大约6个子视图(名为:ABCUI),每个子视图都是从nib加载的:
this.scrollview.DecelerationEnded+= scrollView_DecelerationEnded(...);
public void LoadSubView(int nPageNo)
{
if (this.PageLoaded(nPageNo))
return;
for (int i=0;i<6;i++)
{
ABCViewController abcUI=MonoTouch.Foundation.NSBundle.MainBundle.LoadNib ("ABCUI", this, null); //XIB file size: 20K
abcui.SetTitle(...);
abcui.SetXXXX(...);
abcui.frame = .. pageFrame.X += this.ScrollView.Frame.Width+nPage*...;
this.scrollview.addsubview(abcUI.view,...);
}
}
public void scrollView_DecelerationEnded (object sender, EventArgs e)
{
int nPageNo=(int)Math.Ceiling((this.ScrollView.ContentOffset.X+1)/this.ScrollView.Frame.Width);
this.LoadSubView(nPageNo +1);
this.LoadSubView(nPageNo - 1);
}
public void Button1Clicked(object sender, EventArgs e)
{
this.ClearViewsInScrollView();
this.LoadSubView(1);
}
Run Code Online (Sandbox Code Playgroud)
当用户触发button1单击时,它会将第一页加载到scrollview中(一次只有1页,但是1页有6个子视图),当用户滚动滚动视图时,它将加载下一页.
但是在scrollview中加载第一页或切换页面需要很长时间,因此用户必须等待:
如何优化性能(减少到300ms/ipad1)?
Monotouch/WCF:为什么不能覆盖wcf绑定默认超时设置:
public class MyServiceClient : ClientBase<IMyContract>,IMyContract
{ ... }
public void test() {
BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
basicHttpBinding.Name = "basicHttpBinding";
basicHttpBinding.MaxBufferSize = int.MaxValue;
basicHttpBinding.MaxReceivedMessageSize = int.MaxValue;
basicHttpBinding.ReceiveTimeout = TimeSpan.FromSeconds(10.0);
basicHttpBinding.SendTimeout = TimeSpan.FromSeconds(10.0);
basicHttpBinding.CloseTimeout = TimeSpan.FromSeconds(5.0);
basicHttpBinding.OpenTimeout = TimeSpan.FromSeconds(5.0);
MyServiceClient client = New MyServiceClient(basicHttpBinding, new EndPointAddress(...));
client.Test();
}
Run Code Online (Sandbox Code Playgroud)
//虽然我将OpenTimeout设置为5秒,但是当我关闭服务器服务(或关闭iphone的wifi和网络)时,它仍然尝试在后台连接到服务,直到默认的1 miniute超时,这很奇怪!为什么?谢谢.
顺便说一句,monotouch/iPhone中的异常在1分钟后抛出,类型是TimeoutException(消息:操作已经超时.)不是FaultException或CommunicationException).如果上面的代码在windows .net客户端中调用,则应该抛出CommunicationException.
我已经在main.cs中包装了日志代码以捕获异常,但是通过monotouch构建的app通常会在iPad中崩溃,而我找不到任何日志.(某些代码包含多线程操作和wcf服务)
如何捕获所有崩溃异常?
public class Application
{
// This is the main entry point of the application.
static void Main (string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
try
{
UIApplication.Main (args, null, "AppDelegate");
}
catch (Exception ex)
{
Util.LogException("Main",ex);
}
}
}
Run Code Online (Sandbox Code Playgroud) 为什么不能改变MonoTouch.Dialog.TableView.Background
颜色?我正在使用MonoTouch.Dialog的Elements API.它还是灰色的!
class MyDialogViewController : DialogViewController {
public MyDialogViewController (RootElement root) : base (root)
{
}
public override void LoadView ()
{
base.LoadView ();
TableView.BackgroundColor = UIColor.Clear;
UIImage background = UIImage.FromFile ("Mybackground.png");
ParentViewController.View.BackgroundColor = UIColor.FromPatternImage (background);
}
}
public partial class MyVC: UINavigationController
{
public void CreateTestUI()
{
var menu = new RootElement("MyMenu"){
new Section ("test"){
new StringElement("Test", delegate() { }), ...
var dv = new MyDialogViewController (menu) {
Autorotate = true
};
// add the nav controller …
Run Code Online (Sandbox Code Playgroud) xamarin.ios ×6
ios ×2
wcf ×2
.net ×1
c# ×1
dotfuscator ×1
encryption ×1
exception ×1
indentation ×1
scrollview ×1
timeout ×1
xamarin ×1