How to set timeout wcf on xmarin droid - xamarin.android

My application connects with a WCF service (.NET 4.5). I build proxy using slsvcutil (silverligth 5) and Works fine.
but I´ve having problems with timeout. I get an error over 1 minute.
this it´s my code:
BasicHttpBinding bindin = new BasicHttpBinding();
bindin.MaxReceivedMessageSize = 267386880;
var timeout = new TimeSpan(0, 10, 0);
bindin.SendTimeout = timeout;
bindin.OpenTimeout = timeout;
bindin.ReceiveTimeout = timeout;
wcf = new ServicioInasaClient(bindin, new EndpointAddress(editHost.Text));
Thanks

I solved it with:
wcf.InnerChannel.OperationTimeout = timeout;

Related

How to secure cache.db file in Xamarin.iOS

I'd like to secure cache.db file on iPhone. Now when I install my App and connect the iPhone to my Mac, I'm able to see cache.db file in the apps file structure and I'm able to read the file contents that basically contains requests and responses. I Applied NoCatch with HTTP client object. But not it makes no difference.
HttpClientObj.DefaultRequestHeaders.CacheControl = new CacheControlHeaderValue
{
NoCache = true
};
Translate the solution here with SWIFT into c#:
To prevent request and parameters being written to the Cache.db iOS
If you are using NSUrlSession :
var configuration = NSUrlSessionConfiguration.DefaultSessionConfiguration;
configuration.URLCache = new NSUrlCache(0,0,"");
NSUrlSession seeion = NSUrlSession.FromConfiguration(configuration);
Or set at a global NSUrlCache level:
NSUrlCache.SharedCache = new NSUrlCache(0,0,"");
Update:
You can use native handler when creating HttpClient:
public MainPage()
{
InitializeComponent();
HttpClient httpClient;
if (Device.RuntimePlatform == Device.iOS)
{
var configuration = NSUrlSessionConfiguration.DefaultSessionConfiguration;
configuration.URLCache = new NSUrlCache(0, 0, "");
NSUrlSessionHandler handler = new NSUrlSessionHandler(configuration);
httpClient = new HttpClient(handler);
}else if (Device.RuntimePlatform == Device.Android)
{
AndroidClientHandler handler = new AndroidClientHandler();
httpClient = new HttpClient(handler);
}
//...your request
}
Remember to Add reference to Xamarin.iOS.dll and Mono.Android.dll.
CacheControl HeaderValue works me
System.Net.Http.HttpClient httpClient = new System.Net.Http.HttpClient();
httpClient.DefaultRequestHeaders.CacheControl = new CacheControlHeaderValue { NoCache = true };
Documentation

Enable Seamless mode using AxInterop.MSTSCLib

I have an application that use AxInterop.MSTSCLib activeX to create remote connection to another PC similar to the following application:
http://www.codeproject.com/Articles/43705/Remote-Desktop-using-C-NET
My question, is there an option that I can config to connect the PC in seamless mode?
I know this is over a year old but I am assuming this is what you want to do:
rdp.Server = "Server";
rdp.UserName = "Username";
rdp.Domain = "Domain";
IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();
secured.ClearTextPassword = User.Password;
rdp.AdvancedSettings8.ConnectionBarShowMinimizeButton = false;
rdp.AdvancedSettings8.ConnectionBarShowPinButton = false;
rdp.AdvancedSettings8.ConnectionBarShowRestoreButton = false;
rdp.AdvancedSettings8.EnableWindowsKey = 0;
rdp.AdvancedSettings8.RedirectClipboard = true;
rdp.AdvancedSettings8.RedirectDrives = true;
rdp.AdvancedSettings8.RedirectPrinters = true;
rdp.AdvancedSettings8.SmartSizing = true;
rdp.SecuredSettings3.StartProgram = "LaunchApp Path";
rdp.Connect();
In addition follow what #Hans Passant suggested above..

When migrating from Quartz.Net 1.x to 2.x will I have to change the way my scheduler is configured and started?

Here is how I configure and start my Quartz.Net scheduler in 1.x:
properties["quartz.scheduler.instanceName"] = instanceName;
properties["quartz.scheduler.instanceId"] = "AUTO";
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.threadPool.threadCount"] = threadCount;
properties["quartz.threadPool.threadPriority"] = "Normal";
properties["quartz.jobStore.misfireThreshold"] = "60000";
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.useProperties"] = "true";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.jobStore.tablePrefix"] = tablePrefix;
properties["quartz.jobStore.clustered"] = "false";
properties["quartz.jobStore.lockHandler.type"] = "Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz";
properties["quartz.dataSource.default.connectionString"] = connectionString;
properties["quartz.dataSource.default.provider"] = "SqlServer-20";
schedFact = new StdSchedulerFactory(properties);
svcScheduler = schedFact.GetScheduler();
svcScheduler.Start();
After migrating to 2.x will I have to change something here and what?
Most importantly is quartz.dataSource.default.provider for SQL Server still SqlServer-20 or did something change there?
Nothing has really changed in the configuration of Quartz.net 2.x.
You can find some useful information here.
Yes, you still have to use SqlServer-20 if you want to use MS Sql Server.
For a full list of db provider have a look here.

Creating a process in ASP.NET MVC controller

I have a requirement to run an application through my MVC controller. To get the installation path I used following link (I used answer provided by Fredrik Mörk). It worked and I could able to run the exe through a process. The problem occurred when I deployed this solution on IIS where it did not create the process as it was creating in local dev environment. Can anybody tell me how to create a windows process through a solution which is hosted on IIS ?
private string GetPathForExe(string fileName)
{
private const string keyBase = #"SOFTWARE\Wow6432Node\MyApplication";
RegistryKey localMachine = Registry.LocalMachine;
RegistryKey fileKey = localMachine.OpenSubKey(string.Format(#"{0}\{1}", keyBase, fileName));
object result = null;
if (fileKey != null)
{
result = fileKey.GetValue("InstallPath");
}
fileKey.Close();
return (string)result;
}
public void StartMyApplication()
{
Process[] pname = Process.GetProcessesByName("MyApplication");
if (pname.Length == 0)
{
string appDirectory = GetPathForExe("MyApplication");
Directory.SetCurrentDirectory(appDirectory);
ProcessStartInfo procStartInfo = new ProcessStartInfo("MyApplication.exe");
procStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process proc = new Process();
proc.StartInfo = procStartInfo;
proc.Start();
}
}

How do I forward request to another proxy server using TIdHTTPProxyServer (proxy chain)

currently I want to make my indy proxy server forward the request to another proxy server. I have found this link and made a try by myself. But my code does not work without any error message as if I had made no change. My code is as below in C++ XE2.
void __fastcall TForm3::MyProxyHTTPBeforeCommand(TIdHTTPProxyServerContext *AContext)
{
TIdIOHandlerStack* tempIO = new TIdIOHandlerStack(NULL);
TIdConnectThroughHttpProxy* tempProxy = new TIdConnectThroughHttpProxy(NULL);
tempProxy->Enabled = true;
tempProxy->Host = "localhost";
tempProxy->Port = 8181 ;
tempIO->TransparentProxy = tempProxy;
AContext->OutboundClient->IOHandler = tempIO;
}
Finally I found I did something stupid. The correct code should be as follow...
void __fastcall TForm3::MyProxyHTTPBeforeCommand(TIdHTTPProxyServerContext *AContext)
{
TIdIOHandlerStack* tempIO = new TIdIOHandlerStack(AContext->OutboundClient);
TIdConnectThroughHttpProxy* tempProxy = new TIdConnectThroughHttpProxy(AContext->OutboundClient);
tempProxy->Enabled = true;
tempProxy->Host = "localhost";
tempProxy->Port = 8181 ;
tempIO->TransparentProxy = tempProxy;
AContext->OutboundClient->IOHandler = tempIO;

Resources