i have a C# application, and id like to be able to make a system, so that within the program, you can display the sourcecode of the application. easy enough so far right?
well, i need them to be able to edit that code, almost like the debug break option... then load the new code and continue without stopping the program. so my problem is, that when this app loads its several thousand lines of code, and it takes a good block of time. after its loaded, it needs to do several hundred operations before allowing user input the first time it loads. also, it has a tcp client in it, and it is very important that it does not get disconnected.
i want people to be able to edit the source, click a button, and wait a few seconds, and have the new code inserted and "rehashed" so to speak, without having to break the overall function of the application.
im looking thorough code examples where possible and an input weather this is possible or not
~ thanks
If you want to allow people to make arbitrary changes to your program, that would be very complex. However, if you want to let them change specific behavior (like rewriting a calculation algorithm) you could have a look at Microsoft.CSharp.CSharpCodeProvide as discussed here.
I don't think you can do that (change a .net app without rebuilding it) but you can have dynamic code loaded and run at any time..
Some people use plugins with Boo, people can change the plugins and these can be loaded at any time by the main app.
But I would suggest you have a look at the Ruby usage inside SilverLight..
This is something completely different, but its something I'm reading on how to start playing with Dynamic code handling: here
Related
I have written a rather large application running in the background, doing dome stuff and processing some data.
Now the problem is, for some time the application runs fine. But when I check a day later for example the Backgroundworker of my application seems to loop or stuck. There is no error message and the UI of the application is still running fine. It just stops processing data.
Specifically for this case I added a simple website for myself where the Backgroundworker reports the current DateTime. So when the DateTime on the website is somewhat current I know it is running fine. But when it's in the past I know my application is stuck.
The issue comes after a undefined time. It can be 10 minutes or 90 Hours.
Now for debugging: Is there a way in Visual Studio that I can see where the application currently is? That would make debugging a whole lot easier. Otherwhise I would have to set breakpoints on trial-and-error base...
Best regards,
Julian
you have two options:
1.- attach the debugger as it is suggested already and check the code, but if the application runs fine for a long time, it is not the best idea.
2.- log files. Create log files to track your application.
What I would do: I would combine both options. Add log files to check results and when the application reached certain points (to decide by you) and then, once I know more or less where the problem is, use the debugger.
Good luck
Edit:
I fully concur with this answer but would add that you may benefit from making the background worker pass key position information back to the UI as it enters and leaves particular sections so that you can simply interrogate this when you attach. Since the problem can take several hours to manifest itself you could end up with a lot of log file to wade through unless you use a rolling log with limited entries, continuously setting a telltale would at least allow you to know approximately where to put the breakpoint at that moment.
I am trying to make a text reader, but I found that when scrolling a large document, at some point whenever the texture memory reaches around 15000 the app just exits with code -2147220978 (0x8004020e).
What does it mean? Is there any work around? I really need to be able to read large text documents.
The 8 means "error". The "004" means "this error is specific to the interface that the object was using at the time it failed". The "020e" means... well, it means whatever the author of that interface intended it to mean. (All error codes above 0200 are author-defined.)
These are the hardest errors to track down because their meaning is entirely dependent on what the author of the code that failed intended; there is no universal standard. Some subsystem, perhaps developed by a third party, is failing. If you can figure out what subsystem that is, then you can ask the makers of that subsystem what their error number 020e means.
Can you share minimal and relevant repro code? Just one snippet of XAML And one snippet of C# should be enough.
From what you're saying it really might be overloading the GPU with surfaces until the app crashes. It shouldn't ever happen, so I'm not sure this is the real cause.
In the meanwhile, have you tried virtualizng your ItemsControl? If you're using a ListBox have you tried switching to the new LongListSelector? If just switching to LongListSelector isn't enough, try using ItemRealized and add some prefetching logic. If that doesn't work, you might have to create your own virtualizing logic either by manaully removing the Template from the visual tree once it goes out of view or creating a whole new 3rd party virtualized custom control. Maybe one of the 3rd party control vendors has something that would work here.
As the questions says, I want to write code or debug an appication in real-time without setting breakpoints or pausing/restarting the application.
For example, when I write a game, I want to see what is happening when I change the code for the calculation of the light effects or the AI of the enemies immediately, while running the game on my second monitor.
Update:
Ok, it seems that you guys don't understand exactly what I want.
I want Visual Studio to be more like a WYSIWYG editor...make changes or add new code and see instantly what has changed in my application, without the application to pause it's work.
Update:
I saw this feature in this Video with Java in Eclipse (go to 14:30, where he changes the light effects of the game without stopping it.)
Sometimes. Check out the Edit and Continue feature: http://msdn.microsoft.com/en-us/library/bcew296c%28v=vs.80%29.aspx
Based on the comments, it sounds like you either want a dynamic language (a lot of games are scripted with LUA, or check our IronPython or IronRuby) or you want to dynamically load and reload assemblies, which would require something like MAF perhaps. With that, you could build the bits that you are changing as addins, and then unload and reload the addin assemblies when they change. That seems hacky though, and will likely perform poorly compared to a DLR language.
here is all you want to know abt the Edit and continue feature in Visual Studio:
http://msdn.microsoft.com/en-us/library/bcew296c(v=vs.80).aspx
You can edit the code while debugging, but no instruction will be executed during this time.
If you hit F10, the next instruction will be executed. If you hit F5 the normal execution will continue.
Why not create a resource file with the values to apply. Then have a command you can execute in the app that will reread the file. World of Warcraft has a feature like this. /reload ui
Yes, but unless Edit and Continue is enough for your need you need to design and implement the functionality yourself.
if the change is data driven - just reload the data when some file changes.
if change is in code - consider making that portion of the code to be in separate assembly and dynamically load and rewire the assemebly (may require strongly signed assembly to proper version code). Or dynamically compile code into new assembly (to avoid assembly conflicts in the same app domain).
In all cases you need to figure out how to deal with loosing part of previous state that could be in older objects.
I've tried to read up on a few articles about this, but some of them were over my head at the moment.
I run a program that re-caches some SQL data from an external source. I call this from a WinForm application which manipulates the aforementioned data.
While the Console app is running, I lay over the controls with a panel (with a textbox on it) and try to capture the Console app's stdout into the textbox. It "works", but has some issues with repeating lines and missing lines. Reading the stream after the process ends works fine, but I'm having issues with real-time.
CODE
It worked well for me in asynchronous way. Unfortunately I'm not so familiar with .net to write code from my memory...
Upd:
Spent a couple of minutes and found the page in MSDN. Use Process.BeginOutputReadLine Method, here is the description of the function and a sample of its usage.
I have created a Class Library (called as GNGEngine.dll) which performs some image processing stuff. This dll contains a function ProcessBitmap() as the main function to do searching for specific pattern. I have tested the engine by creating anothers forms application and taking the reference of the dll. I am calling the ProcessBitmap() method of dll by clicking on the button. The forms application takes 8secs to process the image completely.
Now as per clients requirement i have created an exe (console application) file GNGEngineRunner.exe which takes the image filename as the argument. I have created the object of dll class and called the method ProcessBitmap() and passed the file for its processing. The same image now takes almost a minute to its processing.
Is there any specific reason, why it is taking too much time?
Thanks for sharing your valuable time.
First of all you should attach a profiler to see what is happening. If you don't have one you can use the trial version at http://www.red-gate.com/products/dotnet-development/ants-performance-profiler/
Visual Studio has a performance profiler built in, but depending on your VS version it could be anything from nonexistant, crappy or good.
Second, there should be no reason for this. I would guess that the problem is that you have exceptions being thrown because of reference to a non-existing form/GUI-object or similar. Execution-wise Console or WinForm is 100% the same and you can even mix them in one app. The only difference is some references and the fact that you create a console window instead of a form.
Feel free to add more details and possibly some code.
You haven't told us what you're doing or how you're doing it, which makes it near impossible to answer really... but your first step should be to get some appropriate traces of what's going on. Insert a judicious amount of logging (including a timestamp) and then it should be reasonably clear where in your process the time is going. Run it in both the console version and the Windows Forms version. Then concentrate on the bottleneck - possibly asking another SO question with more details.