I have a cross platform app that runs on Windows and Mac. It is using WCF on .NET 4.5.2. In the BasicHttpBinding configuration in the settings file I am setting the transferMode="Streaming". We are downloading large files using this service.
On Windows everything works fine. The WCF method call returns right away and then when I read from the Stream member of the MessageContract object the file is streamed as excepted.
When I run the same app in Visual Studio for Mac I have 2 problems. The first problem is that the transfer mode in the binding is Buffered instead of Streamed.
I fix that by changing it in code after creating the channel. Here is the code I use to do it. Maybe this is the problem:
private IDataService CreateClient()
{
Channel = new ChannelFactory<IDataService>(BindingId);
var binding = Channel.Endpoint.Binding as BasicHttpBinding;
binding.TransferMode = TransferMode.Streamed;
Channel = new ChannelFactory<IDataService> (binding, Channel.Endpoint.Address);
var client = Channel.CreateChannel();
return client;
}
Notice how I read the binding, change the transfer mode and then create a new channel using the new binding. This seemed to be the best way to get the same settings from the settings file, but switch the transfer mode.
When the download method call is made I am able to see in the debugger where the transfer mode on the binding is Streamed, where before it was Buffered.
The problem I have at this point is that even though the transfer mode is Streamed, the download WCF method call doesn't return until the whole file is downloaded. It is acting like it is still in Buffered mode.
Any ideas how to fix this?
It looks like the streaming setting doesn't work in the Xamarin implementation of .net 4.5.2 that we are using. Not sure if it works in later versions or not.
I ended up adding a REST api just for downloading large files...
Related
I would like to use Zebble only for producing UI and all other things I would like to use Xamarin apis/custom http apis/local db or whatever it may be. Basically a UI project with zebble and other things will be in PCLs.
Will it be compatible? Could you please advice?
Yes you can. There is nothing in Zebble that prevents you from using the native APIs directly.
For custom http calls, I recommend using the HttpClient class which is by default available in all 3 platforms of a newly created Zebble project.
For Device APIs, you can of course use the standard API classes of each platform, but to save time and achieve 100% code reuse I strongly recommend using the http://zebble.net/docs/device-api. For example if you want o use the lamp (aka flash, led or torch) you can very easily implement that on all platforms with very little code code:
// Determines if a lamp feature is available on the device.
if (await Device.Torch.IsAvailable()) { ... }
// This will switch the lamp on.
await Device.Torch.TurnOn();
// This will switch the lamp off.
await Device.Torch.TurnOff();
I'm working on a little website using dart.
I have one project for the server, and another for the client app (see picture below)
In the server app I serve the client app from the client project like this
runServer() {
var staticHandler = createStaticHandler(r"C:\Users\Lukasz\dart\linkShepherdClient\web\", defaultDocument: 'linkShepherd.html',serveFilesOutsidePath: true);
var handler = new Cascade()
.add(staticHandler)
.add(routes.handler)
.handler;
io.serve(handler, InternetAddress.LOOPBACK_IP_V4, 8080).then((server) {
print('Listening on port 8080');
}).catchError((error) => print(error));
}
Everything worked fine. But now the changes I do in the client project stopped affecting the site served by the server (a site still loads, just an older version, with slightly different styling, but most importantly also an older .dart script file). When I run the client directly from it's project everything is up to date.
Opening and closing the editor does not help.
Is the dart editor actually creating some sort of cache?
The cache might be from dart:io. You should probably launch a pub serve instance and redirect to this during development anyway. This way any transformers (Angular, Polymer, ...) are applied as well.
When deployed the server should serve the build output of the client.
I'm having a web reference which is being used by both a Xamarin IOS application, Xamaring Android application, and a Windows Store application.
And this all worked very well, until I updated Xamarin.
Now, there is a field that But it works fine for the Android and Windows applications.
I have tried to update the web reference multiple times, with no luck. I have also tried to debug the web service locally, to see if it returns the same , which it does.
When I receive it in my Windows Store app., it looks like this:
And in my IOS app., it looks like this:
It is always the StructureId that is never set, for some reason. And it was not like that before I updated Xamarin.
Anyone who knows what I am doing wrong, or have stumbled onto the same kind of problem ?
That looks like the linker removed unused members. Defaults have not changed (it's not related to your update) but you should check that your application is being built with Link SDK (and not Link all).
If you want a smaller executable and set Link all to achieve this then you'll need to add [Preserve] attributes on the structure you're serializing (e.g. used in web services).
I was able to make it work. I am not sure if it cached anything, or what, but it helped to add some "noise" on the webservice call.
I just added DateTime.Now.Ticks to my webservice URL in Reference.cs, so it would always be a new URL call:
this.Url = "http://somewebsitename.com/ReportService/ReportService.asmx?v=" + DateTime.Now.Ticks;
I am writing an application that has multiple potential user interfaces and I am using MEF to inject the appropriate implementation during startup. One implementaiton of IDisplay uses ExcelDNA (Excel is the interface). The code launches Excel as a process through
var processInfo = new ProcessStartInfo
{
FileName = PATH_TO_EXCEL,
Arguments = PATH_TO_EXCELDNA_ADDIN
};
Process.Start(processInfo);
This works fine except that Excel is now in a seperate memory space so UI callbacks (i.e. Ribbon button clicks) cannot get access to any injected or assigned properties.
One possible solution is to launch Excel first then have ExcelDNA's AutoOpen() hook (which gets called once the add in has loaded in Excel) call the bootstrapper class to configure MEF however I'm wondering if it is possible to share memory between the C# and Excel processes? Would starting Excel via Excel.Application app = new Excel.Application { Visible = true; } resolve? I would try this but have not been able to find out how to specify the path of the ExcelDNA addin for it to load (like above).
Excel will always run as a separate process. So you can't share memory between the Excel process and another process. However, C# code can run inside the Excel process - this is exactly how an Excel-DNA add-in works.
You can also communicate between the Excel process and some other process. One option for this is to use the COM Automation interop - this is what you're doing when you call new Excel.Application from your own executable. You are starting a separate Excel process (or connecting to an existing running process), and then getting back an inter-process communication proxy (the Application object).
If you then want to tell that Excel process to load an Excel-DNA add-in, you can call Application.RegisterXLL(path_to_add_in) to have it load the .xll. How you hook up the Excel-DNA add-in and the rest of your code is still to be figured out.
You might still need some kind of cross-process communication, like .NET Remoting, WCF with named pipes or something like that.
Actually I want to pass data in body of a httpconnection.
Using apache httpclient library in blackberry, integrated jar file in my project but getting compilation error while running my project.
Kindly updated me on the same.
I have not tried using Apache HttpClient lib in a BB project before, because I did not for a moment think it would work...
In short, you need the code to be compatible with J2ME, and compilable using the RIM tool chain. And then we get into other problems....
First of, be aware that networking in BlackBerry is NOT as straightforward as one might wish.
Have a look at this video for the back ground theory: Networking Transports on the BB Platform
Ok, then for some code (I assume here you already went through the trouble of obtaining an HttpConnection):
byte [] bodyBytes = getBodyBytesFromSomewhere();
OutputStream out = httpConnection.openOutputStream();
out.write(bodyBytes);
out.flush();
out.close();//If you are done, which I'm guessing you are
The above code is of course very simplistic, and completely ignores all the many, many errors that will occur during network IO.
I would suggest you also look at this API,this forum entry,and this one. OS6.0 also introduced a new HTTP Connection API - can't find a link for that right now (sorry!)