|
Nearly there - but:
Assembly asm = Assembly.LoadFile(mrttexe);
Type TPInfo = asm.GetType("TProgInfo");
Object tpinfo = asm.CreateInstance(TPInfo.FullName);
string asmver = ((TProgInfo) tpinfo).MRTTVER;
Last fails to compile:
Error 1 Static member 'MRTT.TProgInfo.MRTTVER' cannot be accessed with an instance reference; qualify it with a type name instead
I have tried various combinations, including referencing the Class TProgInfo (as above) via the TProgInfo.cs file.
Pity the Internet wasn't around in 1965!
Pensioner Graham Dean
|
|
|
|
|
Hello again
Graham Dean wrote: although programming since 1965!
Wow!! I wasn't even born yet!!
Graham Dean wrote: Error 1 Static member 'MRTT.TProgInfo.MRTTVER' cannot be accessed with an instance reference; qualify it with a type name instead
Well the error message was clear, & I told you I haven't tested the code -Sorry. My mistake -, Yet everything has a solution.
All in it is that the code will change a bit, here is the new version:
using System.Reflection;
private void MyMethod()
{
Assembly MyAssembly = Assembly.LoadFile("MyFilePath.exe");
Type MyType = MyAssembly.GetType("MyClassName");
FieldInfo fi = T.GetField("ConstantA");
int Val = (int)fi.GetRawConstantValue();
if(Val == MyValue)
{
}
}
As you might have noticed that constant fields in C# are automatically considered as static members. So, you can't call them using instances. Here you will check the value using the name of the class itself, as shown above. Unlike last time, where we created an instance of the class.
I tested the code this time. & I Hope it won't disturb you anymore.
More regards
|
|
|
|
|
Nader and I had an 'off forum' discussion. I confused him further by revealing (a little late) that the constants were strings! Solution was to insert Properties in the Class to be reflected that return the strings then use code:
Assembly asm = Assembly.LoadFile(filename);
Type TPInfo = asm.GetType("MRTT.TProgInfo",true);
PropertyInfo pf = TPInfo.GetProperty("CONSTVER");
Object TI = asm.CreateInstance(TPInfo.FullName);
string constval = pf.GetValue(TI, null).ToString();
Thanks again Nader - works like a charm!
Pensioner Graham Dean
|
|
|
|
|
i have different textboxes in my from on one textbox when i press a tab key i want print one messagebox i am writing thiss code but its not working on tab key although its working on like back key but not on tabkey
plz tell me
Private Sub ItemCode_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ItemCode.KeyPress<br />
If (e.KeyChar = Microsoft.VisualBasic.ChrW(9)) Then<br />
MessageBox.Show("u have pressed tab key")<br />
<br />
End If
|
|
|
|
|
Hello
Is that Visual basic?? You're in the wrong forum. You should go to Visual Basic .Net forum[^]
A quick hint quoted from MSDN in the KeyPressEventArgs remarks:
"You cannot get or set the following keys:
The TAB key.
INSERT and DELETE.
HOME.
END.
PAGE UP and PAGE DOWN.
F1-F2.
ALT.
Arrow keys.
"
So if you want to catch the tab key, use the KeyUp event instead
Regards
|
|
|
|
|
in my setup project
i want my project to check if there exist .Net Framework or No if no instaul it automatic and then instaul my program
how can make this ?
Palestine
|
|
|
|
|
Hello
Follow these steps
1- Right click on the setup project's name in the solution explorer
2- Click on properties
3- Click on the prerequisites button
4- Check on "Create setup progra to install..."
5- Check on your prerequisites -according to your project's needs-
6- Cho0se "Download prerequisites from the same location as my application"
NB.
Please don't take any offense, but revise your english before posting
Regards
|
|
|
|
|
I would like to programatically add in a field to a crystal report at runtime. Does anyone know how I would do this? Thanks.
|
|
|
|
|
Can someone direct me to a good IRC client library in C#\.NET?
I've downloaded Meebey's library but it has alot of bugs and troubles.
If someone has a better one, please send me.
Thanks alot.
NaNg.
|
|
|
|
|
|
I just downloaded that...
Is there an informative article about that?
|
|
|
|
|
|
|
|
Wow I just finished reading the documentation that I needed to read. and i just wanna say, that this is MUCH MUCH MUCH more convinient than Meebey's.
Thanks alot for the documentation.
Realy realy thanks.
NaNg. ^^
|
|
|
|
|
Friends,
I've a Win32 handle to a window of type SysListView32. I want to attach this Window handle to .NET managed object of type ListView . Back during the days of MFC/C++ we did it something like:
CListView *pListView = CWnd::FromHandle(hListView);
size_t itemCount = pListView->GetItemCount();
How can i do the same in C#? The reason behid doing so is that i want to call the methods of ListView object to perform operations on ListViewControl such as getting number of items, clearing all items e.t.c.
Imtiaz
|
|
|
|
|
Hello
Imtiaz Murtaza wrote: I've a Win32 handle to a window of type SysListView32. I want to attach this Window handle to .NET managed object of type ListView.
I don't think it's possible!! The two types are totally different. It's like attaching the handle of a dialog to a windows form.
Imtiaz Murtaza wrote: The reason behid doing so is that i want to call the methods of ListView object to perform operations on ListViewControl such as getting number of items, clearing all items e.t.c.
Sorry!! You got to do it with its native functions
|
|
|
|
|
In drawing event I can change fonts, colors and such properties of tooltip.
I can draw a picture but it seems there is no direct way to change the size of the tooltip
I have to change the bounds. If there is an alternative way, it is also acceptable.
thanx
|
|
|
|
|
Hello
If you want to increase the bounds of a ToolTip, override the Popup event handler, and change the PopupEventsArg.ToolTipSize property.
|
|
|
|
|
HI
I want to convert a word file to pdf file how should can i do it using c#.
Also I am using vs.net 2003 and .net framework 1.1.
Thanx
praveen
|
|
|
|
|
This is a pretty broad question. Word does have export filters for PDF. If you are talking about a generic solution that will take a .DOC file and convert it to .PDF without an interaction, there are quite a few commercial libraries out there that you can link into your application that will do the job.
|
|
|
|
|
Pls can you suggest some commercial libraries. Actually what i want is a component that will provide API's which will take word doc file as input and generate pdf file as output.
praveen
|
|
|
|
|
http://www.convertzone.com/doc2pdf
This one is a batch, but you can find others. I have other ideas for the transform as well , contact me if you need more details.
|
|
|
|
|
i check out the url which you gave but it gives an error and site could not be opened. pls send me details of other ways in which i can convert programmatically a word file to pdf file by just passing name of word file using c#.net
praveen.
|
|
|
|
|
hi
i have some dll that i use it in my c# project.but i don't want that end user access to my dll.how to embedd it to my project and how to use it (Please explain how to use it)??
thanks ..
|
|
|
|