We have developed an EMR software using WPF in presentation and .NET c# libraries in business layer. WCF service call is used to communicate between server and client. The application using WPF user control for all pages and tabs in the pages. Now the problem is as the user loads pages and tabs the memory consumption increases and its not reduces until the application is stopped. Even if the user closes the old pages the memory consumption never decreases. The system goes on slowing down as the user loads more pages and close them. Some time the user closes the application and takes it again. Even that time the application slows down considering to the first time load performance. How can i solve this situation. It has became a bottle neck for the application now. Can anyone help.
You have to use a memory profiler to find out which parts of your code are holding on to the data. Search for '.NET memory profiler'.
I used EQATEC profiler to profile my custom controls in Silverlight, WPF and Windows Phone. It was really useful.
Related
Am working on WPF application. It is taking lot of time to launch the application so one of my client raised performance issue. To solve/identify the issue what is the best solution ? and am using dotTrace profiler to identify the issue but while launching how can I attach process to application ?.
You can launch your application under dotTrace - it's a standard way to profile an app. See https://www.jetbrains.com/help/profiler/Starting_Local_Profiling_Session.html
I have a customer who wants an application for his travels where he can update an online DB, he doesn't want to buy a laptop, he wants a tablet or something similar. I have no knowledge nor desire in creating special apps for mobile devices, I want to create a winform just like I always did when it was targeted for pc. Tablet pcs (which from what I understood is just a regular pc?) are still very expensive in my country.
Is there a simple adjustment to make winform app run on a tablet with android or I have to build a special app for it? Any other solution? (I began in writing a web page for it, but it's much easier using winforms)
Native WinForms applications will not run directly on Android (or any non-Windows platform). You may want to begin by looking into MonoDroid for porting .NET code Android (and Mono in general for porting .NET code to non-Windows platforms).
A successful port across platforms will require that the application be structured in a very de-coupled manner. Core business logic in the abstract part of the application should be easily ported, but concrete implementations (specifically views and data/service access) will require some re-implementation for the different concrete platforms. So the overall architecture needs to be very de-coupled and pluggable.
Is a Windows tablet an option? Using various new technologies at Microsoft (Windows 8, Metro UI, etc.) you could build an application that would target multiple Microsoft-based platforms. This could easily satisfy the requirement of being "a tablet" (if the requirement isn't more specifically "an Android tablet"). However, it won't be the old WinForms style of applications.
In general you'll find that the industry has been steadily moving away from WinForms for, well, this exact reason. It doesn't port to other platforms, and there's a wide variety of platforms in demand today.
Forget convertion i was in a similar position years ago and i did something easier faster and i think smarter.
just make a winform with nice big controls take care of docking scaling anchors etc so that it will look nice and can be used with small smart devices.
Make sure you pass some start program parameters in your app and when a special parameter is passed instead of opening the main typically desktop form of your app open that new one in fullscreen.
Now the tricky parts isnelsewhere. I hade setup a tiny windows 2008 r2 server that allows remote apps to be run on it.
Create a user account that you will allow access to that server and only that app of yours with the specific parameter we talked about. (Ex myapp.exe -remote)
The what ever device he will get you can download the free app like 2x rdp or microsoft rdp in android. Make a new connection to your server (you can use any free ddns you like if you dont have a static ip) and connect with that windows server account you did before.
This account if has been properly setuped will only run your app and will only show that new mini winform you did..
The end user will do a simle click and from his internet connection will do a simple remote desktop that is linited to your app only. (Router configuration is needed once)
That way you will keep maintain just one source code and he will have low bandwidth cost and can continue his work without data loose in case of disconnection.
I use that for years in mobiles tablets and pos systems. Its fast its stable its secure its easy to maintain (nothing on the client side) and you don't waste months of learning wpf or doing xamarin converting.
I want to know what are the differences between a WPF Browser Application and WPF Desktop Application. I know that the browser application runs on IE and FF, but about the technology, is the same? I mean, we can do exactly the same by the two ways? (Of course, maybe with different UI)
I have this doubt because I'm looking for a book about WPF Browser Applications, but I only see books about WPF (I don't know if is in general or is only for desktop applications :S)
A WPF Browser Application uses exactly the same framework as a WPF desktop application and could run with the same UI, but with restrictions on trust which means that some APIs are not available. There a number of challenges in developing Browser application. A Browser app must be signed with a certificate. Some of the trust restrictions are not enforced at compile time and are only discovered at run time.
In the time since Browser Applications were first introduced, Microsoft developed Silverlight which uses a similar though not identical XAML technology. Silverlight is easier to deploy than a WPF Browser Application and may be appropriate depending upon your requirements.
A Browser Application not only runs in the browser but also with less authority. If you need to read and write local files then go WPF. Browser is good is you want rapid deployment to lots of PCs. Other wise I will take WPF Desktop every time. Most WPF books with have a chapter on XBAP. I like McDonald from Apress.
Should I start my new browser based C# program in Silverlight or WPF? It will be browser based but it will be used within our organization only, my program will need to talk to Windows file shares if this makes any difference.
I've only done Windows Form Apps and basic ASP.NET apps so far. I don't want to rewrite this in the near future if Silverlight gets dropped.
What would you recommend for ease of learning and future proofing for a Windows form programmer.
Thanks
Steve
No such thing as future proofing. Certainly not in technology.
I don't think either will get 'dropped' in the near future. Both WPF and Silverlight have a steep learning curve (the XAML, the MVVM design pattern, and moving from Procedural to Declarative patterns). If you learn one, you're basically learning the other too.
That said, it depends on your need. My thoughts are usually:
If it's a website, use ASP .NET/HTML
If it's a simple web application, use ASP .NET/HTML
If it's a LOB (line of business) application that doesn't need elevated system privileges, use Silverlight
If it's a LOB application that requires full system access and elevated permissions, use WPF
There are a lot of Silverlight headaches (functional limitations) you can run into that WPF doesn't have...so unless you need cross platform and lightweight is very important to you, I usually lean toward WPF. That said, each version of Silverlight comes closer to WPF functionally.
I should add the caveat - I hate web based LOB applications. I've never seen one that isn't hacky or doesn't suffer from usability problems stemming from the technology. No, HTML5 doesn't solve these technological limitations and problems. If I'm working on a LOB application, I'd rather devote my time to making it the most business friendly application possible with a competitive feature set, than focus on making it display right in different browsers, troublshooting cross domain security problems, and maintaining a javascript code base.
If you write the application in Silverlight, then it will have to be run inside a browser, unless you make it an Out-of-Browser application. If you write it in WPF, it can be run like a desktop application, but you will have to deploy it on everyone's computer who needs to run it.
If you are not sure of Silverlight, try using Flash instead.
I have been playing a bit with Silverlight and try to port my Silverlight 3.0 application to Silverlight 4.0.
My application loads different XAP files and upon a user request create an instance of a Xaml user control and adds it to the main container, in a sort of MEF approach in order I can have an extensible and pluggable application.
The application is pretty huge and to keep acceptable the performances and the initial loading I have built up some helper classes to load in the background all pages and user controls that might be used later on.
On Silverlight 3.0 everything was running smoothly without any problem so far.
Switching to SL 4.0 I have noticed that when the process approaches to create the instances of the user controls the layout freezes unexpectedly for a minute and sometimes for more. Looking at the task manager the memory usage of IE jumps from 50MB to 400MB and sometimes up to 1.5 GB.
If the process won't take that much the layout is rendered properly even though the memory usage is still extremely high. Otherwise everything crashes due to out of memory exception.
Running the same application compiled in SL3, the memory used is about 200MB when all the usercontrols are loaded. Time spent to load the application in SL3 is about 10 seconds, while it takes up to 3 mins in SL4 There are no transparencies, no opacities set, no effects and animations in the layout.
User controls are instantied on the fly and added or removed in the visual tree on purpose when the user switches from one screen to another. The resources are all cleaned properly when a usercontrol is removed from the visual tree to allow the GC to operate in the background.
I may do something wrong but I could not figure out where exactly nail out the source of this problem. As far as I know there is no memory profiler in SL4 that can help me out to find where to look at. But again I could not be updated on new debugging tools available.
UPDATE:
Silverlight 4 Service Release to fix Memory Leaks: http://timheuer.com/blog/archive/2010/09/01/silverlight-service-release-september-2010-gdr1.aspx
Silverlight 4 has known memory leaks and the fix is currently being tested.
Here is a Microsoft Thread about it:
The user "heuertk" is a Microsoft Silverlight Developer....he explains the issues and the status of the fix...
http://forums.silverlight.net/forums/t/171739.aspx
To be honest despite your assertion "The resources are all cleaned properly when a usercontrol is removed from the visual tree" this where I'd start looking. It really does smell of elements of UserControls not being released properly.
This typically occurs when there are long lived (for example static) objects that raise events that more transient objects attach to. If these event handlers aren't detached it leaves these objects hanging around in memory.
I am keep testing and would like to share what I discovered so far.
It might be helpful to understand the behaviors of SL4.
Since it sounded pretty weird the UIThread can take so long to render a bunch of graphic components and considering Microsoft has improved the render pipeline, I have reverted my solution to SL3 but I have kept SL4 installed on my localhost.
The application uses RIA Services and moving back and forth to SL4 means that I have to do some changes in the code as per released documentation.
The application runs extremely smooth more than it was if it is tested with Visual Studio 2008. The memory usage is lower than it was before when SL4 wasn't installed.
As soon as I switch to VS2010 it is a completely different scenario. Memory grows undefinitely, the layout is slow to catch the user interaction and sometimes it freezes as before explained.
I have disabled RIA Services, by using standard Rest service and the process hasn't changed in quality.
In conclusion, considering I will keep testing in order I can finally understand what is really preventing to get the application running in an acceptable mode, I believe the memory issue is due to the debug process of VS 2010 or a combination of VS 2010 and SL4
Just for your info: there is a memory leak when using Silverlight Toolkit Charts in Silverlight 4.0. This is a known bug and Microsoft is working on it.
Silverlight 4 is Leaking everywhere. It Doesn't release memory properly.