|
Thanks for your answer, Kythen.
However, this is bad news for me...
I need to call a method that is already on the stack. I cannot load it with ldvirtftn because I don't have it at the time when I'm generating the code.
The situation is like this: I'm trying to generate the following class:
public MyClass {
public delegate Object DirectReadAccessor<T>(T firstArgument);
private static DirectReadAccessor<MyClass>[] directReadAccessors;
public Object DirectRead(int i) {
directReadAccessors[i](this);
}
public static void InitializeClass(MethodInfo[] directReadAccessorsMInfo) {
int length = directReadAccessorsMInfo.Length;
Type[] typeArguments = new Type[] { typeof(MyClass) };
directReadAccessors = new DirectReadAccessor<MyClass>[length];
for (int i = 0; i < length; i++) {
directReadAccessors[i] = (DirectReadAccessor<MyClass>)
Delegate.CreateDelegate(
DirectReadAccessor<MyClass>,
null,
directReadAccessorsMInfo[i].MakeGenericMethod(typeArguments)
);
}
}
}
* About open instance methods (and other things).
This has been tricky because MyClass doesn't exist when I'm trying to declare the field directReadAccessors , which is of type DirectReadAccessor<MyClass>[] , or when I emit the method InitalizeClass , which again uses MyClass , that doesn't exist yet (that's what I'm creating). However, I've managed to do all this, but now I'm having trouble with method DirectRead , since I don't know how to call the delegate once I have it on the stack. Apparently what I need is the following emit:
ilGenerator.Emit(OpCodes.Callvirt, invokeMInfo);
where invokeMInfo is the method Invoke on DirectReadAccessor<MyClass> , and which I should obtain like so:
MethodInfo invokeMInfo = typeof(DirectReadAccessor<MyClass>).GetMethod(
"Invoke",
BindingFlags.Instance | BindingFlags.Publ<code></code>ic | BindingFlags.NonPublic,
null,
new Type[] { typeof(MyClass) },
null
);
Again, the problem is that neither MyClass nor DirectReadAccessor<MyClass> exist yet. I have the TypeBuilder for MyClass and the unfinished DirectReadAccessor type, which I've created like this:
directReadAccessorType = typeof(DirectReadAccessor<>).MakeGenericType(typeBuilder);
But if I try to call GetMethod("Invoke", ....) on directReadAccessorType as shown above I get a NotSupportedException , because I cannot obtain the method Invoke for an unfinished type. I've tested this assumption by making the same call after finalizing the type with:
typeBuilder.CreateType();
And indeed I do not get the exception in that case. However, I need to be able to get the Invoke method's MethodInfo before finalizing the type, while I'm emitting the code for InitializeClass .
It's a strange situation: I'll have the delegate when I need it, but I cannot produce the code to invoke it. Can anyone offer any help?modified on Friday, March 5, 2010 3:23 AM
|
|
|
|
|
In case anyone is insterested, they answered this for me at stackoverflow. The following call works:
TypeBuilder.GetMethod(directReadAccessorType, typeof(DirectReadAccessor<>).GetMethod("Invoke"));
|
|
|
|
|
Good morning all,
I am currently working on enslaving the webbrowser control to be an editor the way I like it.
One problem I steped into was the lack of beeing able to supply a target for links.
My first approach was to write my own Link-Selection window (no problem here) and it works like a charm on all text-selections.
But unfortunately not on images...
Is there a way to get the selected image?
If my text-range is empty I at least know that I have to deal with an image, but unfortunately not on which one.
I was able to iterate the link collection of the document before saving it and add a target there via setAttribute, but still I would like to know how to get the selected image.
I noticed that when using the execCommand (CreateLink) the selected image (which got a border with the resizing dots on the edges) gets a selection overlay that I am also not able to reproduce. Maybe changing the selction into that would solve the problem...
Any ideas on this one?
best regards and have a nice day
hoernchenmeister
|
|
|
|
|
Iam very new to this community, i want to read a .doc and display it to console. I tried with the following code but getting some garbage values in addition to actual code.
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
StreamReader file = new StreamReader("D:\\keywords\\id1.doc");
String st = "";
while (st != null)
{
st = file.ReadLine();
Console.WriteLine(st);
}
file.Close();
}
}
}
Can some body helpme out with the Process for reading a .doc file...
Thanks in Advance....
|
|
|
|
|
Message Removed
modified 23-Nov-14 7:08am.
|
|
|
|
|
|
I suggest looking at that example again. That code is not specific to a Windows Form application. It can be used in both, aybe with a tweak or two to fit specific requirements.
|
|
|
|
|
|
Whell, abouve post all requiers Office installed.
If you want independed application, start reading this: Office Binary Protocol[^]
|
|
|
|
|
You will need to use something like Office Interop or the open source NPOI[^] library.
|
|
|
|
|
I used crystal report XI in my application and include merge module for crystal report XI in setup when I deploy it at client while I user want to see report; following exception is occurred.
System.IO.FileLoadException: Could not load file or assembly 'CrystalDecisions.Shared, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'CrystalDecisions.Shared, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304'
Can any one help me to resolve this issue.
Thanks in advance.
|
|
|
|
|
You have to reinstall Crystal Report.
Probably it will be useful.
|
|
|
|
|
Thanks Mr. Mohammad.
But I need solution at client end. i think
I need run time for crystal report XI to deploy at Client.
can any one tell me where i will find it. or any other suitable solution for it.
Thanks again.
|
|
|
|
|
I have a medical software and I want to know what's the best control to use and what's the best SQL field type for blood pressure?
The blood pressure as you know is in this format: 999/999
it also has a flag for either right hand (L) or left hand (R), something like radio control
I don't want the traditional way!! I mean two numeric and two radio?!
I thought of the ButtonEdit from DevExpress with a ###/### mask but I faced a problem with the L and R flags..
What is your advise?
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:08am.
|
|
|
|
|
but only one will be used at the time. you know when you are visiting the doctor, he will take the blood pressure sometimes from your right hand and sometimes from your left hand d so why do I have to show both if only one will be shown, well, it's very rare that doctor will take blood pressure from both but i can then consider as new row in the sql table but my issue is what's the best way to do on the form and in the sql server table?
|
|
|
|
|
So, the 99/99 is the systolic/diastolic blood pressure which may be for either the left or right arm, but sometimes for both arms?
I'd use a tab control that contains two tabs. One tab would say "Left Arm" and the other would say "Right Arm". Each tab would have a label that says "Systolic / Diastolic" and a MaskedTextBox with the mask set to "990/990". I believe "9" means "digit is optional" and "0" means "digit is required". That would allow the user to enter a number between 0 and 999 for the systolic value and for the diastolic value. That would also allow the user to enter a blood pressure for the left arm and/or the right arm.
As far as storing it in the database, you could make it complicated, but I'd just keep two varchar fields (one for the left arm and one for the right). One field could be called LeftArmPressure and the other RightArmPressure. You could store each as string like this: "120/80". Then you just serialize/parse as necessary. If you wanted, you could create four fields (LeftSystolic, LeftDiastolic, RightSystolic, RightDiastolic) or you could normalize the field into a new table that points back to your primary table, but that is more complicated than it needs to be. Unless you need indexing on both the systolic and diastolic (unlikely), I'd just go with the two fields.
|
|
|
|
|
but i am trying to reduce number of controls on the form?!
is it possible to have one control, textbox for example with a mask of (999/999 Left) or (999/999 Right)? then save each separately in sql?
|
|
|
|
|
The tab control is probably the best option if you want the user to have the option of entering both a left and right value. Since the user only sees one tab at a time, that reduces the amount of space used by the controls on the screen. And you only have to interact with the two textboxes in the code.
If, however, you only want the user to enter either a left or a right, you would only need a textbox and either a button or a combobox. The user would enter "999 / 999" in the textbox. If you went with a combobox, you'd just add two items to it: "Left" and "Right". The user would select whichever. If you went with a button, you'd just have the text change when the button is clicked. When it says "Left" and is clicked, it changes to say "Right". And when it says "Right" and is clicked, it changes to say "Left". The code would be something like this:
private void button1_Click(object sender, EventArgs e)
{
if (button1.Text.ToLower() == "left")
{
button1.Text = "Right";
}
else
{
button1.Text = "Left";
}
}
Also, if you wanted to add a third item to the combobox that says "Left and Right", the user might then enter text like "999 / 999 | 999 / 999". But you'd want to make it clear to the user that they should type it in that format (a MaskedTextBox is one way to do that).
If you are really ambitious, you could create a custom control that acts like DateTimePicker. The text is displayed like "999 / 999 Left". When the user clicks on "Left" and presses up or down, it changes to "Right" and when the users presses up or down when it says "Right", it changes to "Left". And when the user clicked on one of the numbers, pressing up or down could increment or decrement the numbers (and page up / page down could increment/decrement by increments of 10). You might even be able to get away with that by using a TextBox and using the events (such as key presses and mouse clicks) to create that functionality.
|
|
|
|
|
Hi,
I suggest you store the systolic and diastolic pressures in separate, numeric fields; don't turn them into a single string in your database. Use strings for texts, and for types the database cannot handle in any other way, but not for numbers.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Now that I think about it, this is probably a better idea than combining them into strings. Makes working with the data easier in SQL. The data is also smaller that way.
|
|
|
|
|
can anyone help plz..
I want to have a textbox with a mask of ##0/##0 Left and ##0/##0 Right so user must both number and select either L or R to display Left or right
|
|
|
|
|
You are in luck. This post describes how to do just that.
jrahma wrote: select either L or R to display Left or right
What do you mean by this? Select what? A combobox? A button that toggles the text? A toggle button that is inside of the textbox? The keys "L" and "R"?
|
|
|
|
|
isn't it possible to have it all in the textbox without the button?
|
|
|
|
|
That's exactly what I described in the post I liked to. Read it.
|
|
|
|