Protecting Wpf Prism application with Smartassembly - c#

I am trying to protect my wpf application with SmartAssembly. I have problem because exe created by SmartAssembly don't work propertly. When I run app I see white screen and app is not responding. Depending of configuration sometimes app is closing. Under some SA configurations application is not responding for about 2 minutes (durning that time it uses a lot of CPU and RAM). After 2 minutes it starts to response but without any navigations between views.
I tried many configurations (even without any protection selected), and so far couldn't make it work. In my opinion problem is in loading Prism modules because in reports I get many
Prism.Regions.Behaviors.RegionCreationException
MicrosoftPractices.Unity.ResolutionFailedException
Could you tell me how should i configure project to make it work?
Thanks in advance for help

Related

Why does my WPF UI lag when streaming lots of IP camera's in a single instance, but not when running the same amount of streams in multiple instances?

We have created a WPF application which allows you to livestream multiple IP cameras(Mobotix). This application works fine when connecting it with a few streams. All streams are rendered correctly and without any delay.
However when we try to run the application with more than 20 livestreams, we experience problems with some steams no longer updating and the UI of the WPF application lagging.
We can fix this issue by turning down the quality and/or size of the livestreams. But unfortunately this is not acceptable as the images do not contain enough detail.
After a lot of debugging, and trying with different ways to display the steams, to no avail, we noticed that if we run multiple instances of same application each rendering a limited amount of steams (for example 3 instances with 8 livestreams each), that there are no issues with any of the instances nor the camera streams themselves.
With this information we were wondering why there is a difference with one instance of the application running 24 streams or 3 instances of the same application running 8 streams each.
Does anyone here know what causes this behavior? Is there some sort of memory limitation for each application instance? Or a limitation of some kind in the GUI thread of a WPF application? Maybe there are other things we are failing to see here?
Any help would be highly appreciated!

WPF C# Application Performance

We have a C# WPF application written in .Net 4.0, which some relatively simple data binding and grid functionality.
The styling invovles a few 'tweaks', including some hover colours and so on.
On 3 machines, out of a deployment covering 20, we are experiencing some very strange performance problems with the UI.
Effectively, after a reboot the application performs well, but after a certain (un-determined) amount of time, the UI becomes incredibly sluggish. For example, hovering the mouse over a button, and there will be a delay of up to a couple of seconds before the hover colour styling gets applied / rendered.
The machines have almost identical specifications. The graphics drivers have been updated, and the starndard setup is two NVidia Quadro 290 cards. Additoinally, we made a 'test' application containing ONLY some test UI components (including the Fluent Ribbon) and no code behind. The problem still occurs.
I have run the Windows Performance Suite to 'deep dive' the runtime WPF, and, very strangely, the UI returns to normal responsiveness if the option 'Disable Dirty Region Support' is ticked. My understanding is that, if anything, this should decrease performance further!!!
I'm at a loss of anything else to try here. A DotTrace performance analysis suggests most of the application time is spent in the PresentationFramework.dll.
[EDIT] All machines are Windows XP SP3.
[EDIT] It is possible that this occurs on all the machines and that the application is not usually allowed to run for long enough to present the problem. We are testing this now.
[EDIT] I should also point out that we are experimenting with the hotfix detailed here. It has been installed on a single machine for the moment, and I will update accordingly.
[EDIT - 24 hours later] So two machines have now been running the same code overnight. On my machine (which has never demonstrated the problem), after initial log in the application was very sluggish, but after less than a minute returned to normal. (I put that down to the machine clearly pulling things off the HDD). On the other machine (which usually demonstrates the problem), the applicaiton improved after a few seconds, but is still now sluggish in comparison to mine.
[EDIT - 48 hours later] On the test machine, the test application is now completely unresponsive (locked) after running for 48 hours. On the same machine, a lightweight 'shell' WPF application (containing a tab control, some buttons and a few panels and grids) is still running and perfectly responsive. So something in these more complex controls is causing this issue... which does indeed point back to (potentially) triggers and delegates that might be the root cause. I'll look to profile the application / controls again. In the mean time does anyone have any advice about how to ensure that the application 'cleans up' after itself at regular intervals? Because we are looking at third party controls here, so my options for editing them are limited!
Would appreciate any tips that can be provided!
try to render wpf in software mode.
in Loaded event:
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
HwndTarget hwndTarget = hwndSource.CompositionTarget;
hwndTarget.RenderMode = RenderMode.SoftwareOnly;
Something to consider when comparing performance between developer and user machines is the time it takes to load the WPF assemblies.
On a dev machine you might already have visual studio running or have previously run other WPF apps and the assemblies should all have been loaded by the time you run your app.
On a user machine, perhaps freshly rebooted, the assemblies will be loaded when the app is started, making startup significantly slower. Depending on how the app is setup there might be additional assemblies loading when various features / pages are used for the first time.
I've found the EQUATEC profiler to be useful in debugging these performance issues. Changing the profiling to "Full usual info" in the app options before building your project will profile down to the binding level.

WPF Application Slow Unresponsive when demonstrating using remote sharing software

After spending 14 hours on this I think its time to share my woes and see if anyone has experienced this issue before.
Ill describe the issue and tests I have done to rule out certain things.
Ok so I have a WPF application which loads in data from an SQL database.
I am using DevExpress Components for datagrids, ribbons etc.. and FluentNhibernate to provide a session for database operations. I am also using log4net to log events to a textfile.
Using the application on my laptop with SQL Express 2008 works fine.. the application starts up, retrieves 1000 records and I can tab through the controls on the ribbon.
Now, I decided to demo the application to a third party and used remote login/sharing software online to share my desktop with the other person so as I could load the application on my laptop and they could view me using the application.
Now, the application takes approx 45 seconds to load... 30 seconds with a blank database where as, when im not sharing out my screen using the online software the application loads in about 7-10 seconds. As well as that, even using the controls in the application during the demo were very sticky, slow and unresponsive.
During the sharing session though however I was able to use other applications without any problems.. everything else worked fine.
But I cannot understand how my application works ok under normal conditions , even browsing the net at the same time etc... BUT totally fails to perform correctly when I am sharing a session with another user... the CPU usage shot up to 100% too at times when the application was trying to start up...
Please see below a list of 3rd party dlls I am using as references in my project.
DevExpress dlls
FluidKit
PixelLab.WPF
PixelLab.Common
Galasoft WPF Kit
FluentNHibernate
NHibernate
Nhibernate.ByteCode.Castle
Skype4ComLib
TXTEXTControl
log4net
LinqKit
All of these DLLs are in the output folder with the application dlls created from the class assemblys in the project. So when installed via an installer on a machine the dlls will be in the same application folder as the application file itself.
Many thanks
I saw something similar about a year ago with logmein. The performance is not the app its the graphics processing . WPF renders graphically in a completely different way then GDI winforms see around 2.3 and down msdn article. Many remote desktop application have trouble rendering this correctly particularly if you don't use the plug ins (say logmein). You didn't say what you were using but I would suggest trying a few different RDP options as there are many out there, and making sure your on the newest versions.
Yes, as bumle-bee-tuna points out, WPF will default to software rendering over Remote Desktop. Another way may be to screen share using Skype or similar. This means you'll be rendering the app locally but transmitting an image to the remote user. the app should work at full speed and the only lag the viewer will see will be introduced by the Skype network. I've used this technique many times to deliver presentations remotely and works well!

.Net Application extrem slow. After killing svchost.exe it runs again fast. Any idea?

I've a C# .Net 3.5 Application (x86) running on Windows7 x64.
For any reason after a few days or weeks the App runs extremly slow.
All other Apps runs normal (also another C# .Net 3.5 Application (x86)).
After killing a few svchost.exe the Application runs normal again. Rebooting without killing svchost.exe also doesn't help. Probably Windows saves the state of svchost.exe. If I logoff the user and login again it also works again, without killing the svchost. On logoff the svchost is probably cleared.
Does anybody have an idea how to solve the problem?
Greets
Wowa
EDIT:
The Main-Form is just an MDI-Container with a Treeview on the left-side with static nodes.
The Application checks on start for Updates via networkpath (checks files creationdate), but this can't be the problem, because all other PC works without a problem.
After the Update every MDI-child-form takes 1-2 minutes to start, even a empty form.
EDIT:
Sorry, i've forgot, that the updating is no more done by this application, but by another, which has nothing to do with the app which runs slow.
The app which updates the slow app runs normal. It only updates the slow app if it isn't running.
But the slow App removes files in the local Temp-path. System.IO.File.Delete()
Without any details or code as to how exactly your application checks for updates at startup, I'm going to guess that it's doing it on the UI thread (main thread), and blocking your application while doing it.
You mentioned that it's checking for updates via networkpath, I'm going to assume that you mean network share, in which case this might be the reason one of the svchost processes is acting up. Get Process Explorer, and use it to determine exactly which services are started by the offending svchost (by looking at the hint, or the Services tab in the process properties):
Perhaps it could be related to virus scanning software. If you have it installed, disable it and try the process again.
Same thing has been weighing us down.
Acrobat InDesign CS5 ME ver. (x86 app)
We have tried and tried again (Win7 64; 2gb; 1gb video card). I have noticed scvhost # 50,000 sitting in Taskmanager; killed it, but comes back. We haven't upgraded yet because of this.
We run the same app on XP-32, and also have some trouble, but that i more likely because of only 128mb video memory (2 P4 chips, 4gb mem).
I have peeked in ProExp but didn't know HOW to look. Thanks for the tip.
Hey, I'm a plain guy, not a pro programmer.

Making a Background Service Somewhat Like Apple's Spotlight in VIsual Studio C#

I am about to start working on an application that runs in the background waiting for a certain user input somewhat like apple's spotlight.
Basically the user will give the service a certain key combination that will bring it up (i.e. CTRL + Space or CTRL + p) and the application main GUI will be brought up.
Now my questions:
First, I want this application to have a very small footprint and not draw on many system resources, and not interfere with the operation of other applications.
I also would like to write this application in C#. So far the best idea I have had would be to write a service that listened for key strokes and threw away stroke that were not either the control or following a control key.
This does not seem optimal is there a better way, anyone know how spotlight works?
Second, I am concerned that this kind of service might be identified as mall ware.
What steps might I take to ensure that my software is not targeted by applications such as Avast and Spysweeper?
Would I need to contact all of the manufacturers of these software packages and explain the purpose of my application?
Finally, if anyone could link to resources about how to set up such a service I would greatly appreciate it.
Services are not supposed to interact with the desktop user, as such they aren't supposed to be able to hook and watch for keystrokes. This may work on XP but you will likely have many problems on Vista/7 and later OS's.
You really need a userspace program that runs at user startup to do this that runs as the same user as the logged in user.
Also, if you are concerned about minimal footprint and resource usage, you don't want to be using .NET because it needs to load a fairly large runtime library and creates a fairly big working set. Usually this isn't a problem, but for something like a watcher program, it's best to write it in low footprint C using a low footbring minimal CRT startup.
My suggestion would be to create a winforms application, add the system tray icon using NotificationIcon to the main form of the application. Then hide the main form. The application can receive key strokes, particularly if you set the FormsPreview property to true. You might also need to hook into the windows api keypress events.
You should be safe from Malware scanners.
You may want to take a look at this link for setting up a system tray/win forms app.
How can I make a .NET Windows Forms application that only runs in the System Tray?

Categories