|
PIEBALDconsult wrote: Ah, classes you didn't write, I see.
Yep.
PIEBALDconsult wrote: That's probably not a good idea, but maybe someone can figure it out.
What isn't a good idea? If you mean the undo, it's a very important requirement of the system, and it's completely necessary. There are transactions running in the system, and if they fail I need to roll them back (undo what they've done). It's pretty standard, and I've seen it done at a higher level in Java, but the way they do it isn't possible in the .NET framework.
EDIT: I should clarify something about the "undo": it's not that you let the transaction write whatever it wants to memory and then with the undo change it back to how it was. Rather, when the transaction wants to write to a field I intercept the write and write to the transaction's write log instead (write, write, write). If the transaction commits (i.e., finishes successfully) I dump the contents of the write log to memory (actually perform the write it requested). Otherwise, if it rolls back, I simply discard the contents of the write log and they're never written to shared memory.
In any case I need to be able to monitor all accesses in order to register them and redirect them to the write log, if necessary.
|
|
|
|
|
I would use Mono.Cecil to modify the binaries on disk.
Ideally you'd add a reference to a helper assembly, and use Cecil only to replace the ldfld/stfld instructions with calls to a method in your helper assembly (passing the field by-ref and/or as metadata token).
However, there's another option for bytecode modification that's not well-known: the .NET profiler API.
Using the profiler API, you can register a hook that will be called by the .NET framework to modify the IL bytecode immediately before it's JIT-compiled.
This way you can also instrument code that's dynamically loaded (Reflection.Emit). But it's much harder to use than Cecil because any changes to metadata (e.g. adding a reference to one of your methods) have to be registered with the running .NET instance, and there are some limitations on what metadata you're allowed to change at run-time.
Are you trying to implement software transactional memory for .NET? Even using the powerful profiler API, you'll likely run into limitations (e.g. when .NET calls into native code), not to mention performance problems.
|
|
|
|
|
Uhm... How did you get into my head? (or maybe they're the only two good options for this )
I was currently thinking about doing a combination of the two things you mention: implementing the profiler API and modifying the bytecode with Cecil whenever a class is loaded. My current idea (not very pretty right now, until I find something better) is:
1. Get notified whenever a class is loaded. The profiler API has a callback method for this.
2. Weave (modify) the class, if I haven't already modified it.
3. Unload the old class.
4. Load the new class. (I think that in order to load it as if it were the old class I need to write it to the .dll and then reload it; I don't need to tell you, this is pretty ugly)
And then forget about monitoring the code because I have already injected the control code into the class.
If could replace the class in a more straightforward way, like you do in Java by implementing a ClassFileTransformer, that would be great. I'd rather not monitor the code and just rewrite classes as they are loaded, but I currently don't know how to do this. Any input on this front?
Daniel Grunwald wrote: there are some limitations on what metadata you're allowed to change at run-time.
I don't need to change much, just replace the stfld or ldfld instruction with a call to a method that takes care of resolving any possible conflicts, logging, etc.
Daniel Grunwald wrote:
Are you trying to implement software transactional memory for .NET?
Yep.
Daniel Grunwald wrote: Even using the powerful profiler API, you'll likely run into limitations (e.g. when .NET calls into native code), not to mention performance problems.
Tell me about it, I keep bumping into walls. I wish I had an alternative, but this is a project I was given and I can't really change it. It's an STM in C#. In fact, it's a pre-existing STM, so I don't get much choice on how it works, just on how (how?!?! ) I manage to get it to work.
Thanks for your answer. If it wasn't exactly what I was thinking about it would've been really helpful . (Where were you yesterday before I thought this up? )
EDIT: I've just found the profiling API callback method JITCompilationStarted, which looks way more appropriate for my purpose than the ClassLoadStarted/ClassLoadFinished ones that I planned to use. According to this resource[^] it will allow me to view and modify the IL before it's JITed, which is exactly what I need. I don't know how I had managed to overlook this method until now. (Granted, I only found out about the profiling API yesterday, but still)
modified on Wednesday, April 14, 2010 1:22 PM
|
|
|
|
|
Hi all,
I am running the aspnet_regiis command from my application (as code example shows below). Is there any way to read the output that is displayed on the command window?
Process start = null;
start = Process.Start(new ProcessStartInfo()
{
FileName = @"C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe",
Arguments = string.Format("-pef connectionStrings {0}", webConfiguraitonFilePath),
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden
});
start.Start();
Many thanks in advance.
Kind regards,
|
|
|
|
|
A quick bit of googling revealed this article: How to redirect Standard Input/Output of an application[^]
It looks like you'll need to amend your code in a similare way to below:
Process start = null;
start = Process.Start(new ProcessStartInfo()
{
FileName = @"C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe",
Arguments = string.Format("-pef connectionStrings {0}", webConfiguraitonFilePath),
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardError = true,
RedirectStandardOutput = true
});
start.Start();
StreamReader outputReader = process.StandardOutput;
StreamReader errorReader = process.StandardError;
|
|
|
|
|
Hi Martin,
Many thanks for the reply, I will definitely try it out.
Kind regards,
|
|
|
|
|
Just remeber to set the UseShellExecute property to false.
Process start = null;
start = Process.Start(new ProcessStartInfo()
{
FileName = @"C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe",
Arguments = string.Format("-pef connectionStrings {0}", webConfiguraitonFilePath),
CreateNoWindow = true,
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardError = true,
RedirectStandardOutput = true
});
start.Start();
StreamReader outputReader = process.StandardOutput;
StreamReader errorReader = process.StandardError;
Thanks again.
Kind regards,
|
|
|
|
|
|
Hi,
How to draw semi transparent boxes(rectangles) in richtextbox control
Any help would be greatful.
|
|
|
|
|
Hello, Hope this is the right forum.
I'm working with web application (C# and asp.net) and I was wonder what are the disadvantages of start working with winforms (clickonce) instead of web applications?
I didn't found any new discusses about that.
Are there any things I can do with web forums that I can't do with winforms?
Thanks in advance,
Roy.
(I u think there is a beeter form for this - please tall me).
|
|
|
|
|
|
Hi,
I saw this article but it seems kind of old (internet explorer 6?!).
I thought that may be there are new differences with the advanced ajax and clickonce today.
Thanks,
Roy.
|
|
|
|
|
It depends on what the app does and/or should do.
Also if you want the app to be publicy available the go for web ASP/SileverLight/whatever suits your
needs and or style.
If the main reson of the app is to introduce data and some small reports than I would recomend
winforms/WPF/localapps/desktop apps simply because they are significantly more responsive.
Another option to consider is:
- is the app for internal enterprise/plant/firm usage?
- should it be available outside usage? If yes the whole app or just some small reports for management?
There's no absolute answer.
|
|
|
|
|
Thanks for the reply!
I will take it into consideration.
Roy.
|
|
|
|
|
There are several elements you have to consider when regarding web vs. winform.
First what does the application do? Do you require rich content with complex process (like a language processor) then you need to deploy a winform application.
If you don't have need for a rich application and can live with simpler controls, then web is the way to go.
If you need a rich experience with a choice between web and out-of-web experiences then you should consider Silverlight. SilverLight presents itself as a web application but can also be built to be an out-of-browser application with a development process closer to that of a winform application.
For myself, I've always been a backend...service based...winform developer. SilverLight gives me the development experience closer to a winform application which is much more comfortable for me than web is. (But stay aware of the fact that you must make service calls asynchronously which adds quite a depth of complexity in the design process.
|
|
|
|
|
hi,
i want to host a control in a datagrid cell(single cell) not the entire column.is there any easy way for doing this?
|
|
|
|
|
Check out this msdn link[^].
|
|
|
|
|
this is for entire column i think i need to add a control to only one cell i.e first cell of grid.
|
|
|
|
|
I have 2 questions.....
1) Are you binding your grid dynamically or is it fix and records won't change?
2) Why you need control only in one cell, is there any specific purpose?
|
|
|
|
|
i made a project for my final year that has a robot which is controlled via Wiimote.
now i want to add a surveillance camera to it...
so i just thought if i can use my mobile phone (mine is motorola A1200) or any other mobile phone as a webcam which will send videos or images to the C# appl. through bluetooth...
i have found applications which access the webcam in C# but couldnt find anything related to bluetooth cameras
if someone can post some links or codes then it would be really helpful
thanks in advance...
|
|
|
|
|
Hi all
1.I would like to copy(programmactically) some tables(Mysql DB) from server into local machine(MS Access) when a user login is successful.
2.After a user has done something on local database, (eg. update, insert etc), the changes will update back the sever database.
Is there any idea pls? Could anybody help me?
Thanks in advance.
Kyi Kyi
|
|
|
|
|
Are the client and server on the same network? If so you can connect directly to the server from your app and transfer the data. Otherwise you'll need a web service to access the server data
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
thank you very much. I'll try.
|
|
|
|
|
1.Get the DataTable from the MYSQL SERVER. and then insert the data to the MS Access.
2.compare the difference of data between MYSQL SERVER and MS ACCESS and then update the changes back to MYSQL SERVER.
This web site is useful for you about the connection string.
http://connectionstrings.com/[^]
|
|
|
|
|
thanks yu-jian
|
|
|
|