|
HI,
I'm New To All System.Reflection Area
is there a Way To Get ClassInfo From a DLL
Where There Are Some Classes.
Have Fun
Never forget it
|
|
|
|
|
By using System.Reflection namespace, you can get various information about an assembly. You can;
- Get the class names in that assembly
- Get the function names in a class
- Get the Parameter info of a function
Here are some code samples to do the things above:
To load an assembly dynamically:
Assembly MyAssembly = Assembly.LoadFile(Application.StartupPath + "\\MyDll.dll");
To get the class names in an assembly:
Type[] myClasses;
myClasses = MyAssembly.GetTypes();
To get the function names in a class:
MethodInfo[] mi;
mi = myClasses[i].GetMethods();
To get the parameter information of a specific function in a class:
ParameterInfo[] pi;
pi = mi[i].GetParameters();
Regards
Zafer SAVAS
|
|
|
|
|
Just as a note, MyAssembly.GetTypes() does not just return classes, but also interfaces, enumerations, etc. If a Type represents a class, it will have the IsClass property set to true
|
|
|
|
|
|
Hi there.
Firefox browser saves site's icon into the base64 string in its bookmark HTML file.
Like this :
<A HREF="http://en-us.www.mozilla.com/en-US/"
ADD_DATE="1183006386" LAST_MODIFIED="1212431053"
ICON_URI="http://en-us.www.mozilla.com/favicon.ico" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/
9hAAABEUlEQVQ4jbWSsXEDMQwEL0CIWAWwBdTCFtgCU0Xs4bMPVAgL+GZUwTrg/
5uS7JECGwlnOLzF4UDpr6u1RkqJkIgIWmv03nkrvN/vRAQhsUks+1mkAZN+B63
rDTOj7MIicZUgxlkkUkq4+88AMzsB7J23GLCrxKYg50xKiUXiRdxaw8xYdgD67
nyAmOBlHgfA3cfsMR7NggN2ZHLcLftYp4Pn7jMgJNydnPOjkwgEnGtbJsH1CXh
sotZKiTjDlpnRe8fdT9E2Cee7I5daKwpRShkOzAx3f5l9k7hcLoREzplaK4uCC
LGuNx620Ht/sb5Ntt/+xFor8Zx87El/Ur13Yg9n7p5z/gwwg47w3H0E9Z/1BfA
kJDRE3FKkAAAAAElFTkSuQmCC" SHORTCUTURL="mozila"
LAST_CHARSET="UTF-8">Mozilla - Home</A>
Now, I want convert it to an image.
for this, first I omitted data:image/png;base64, and other needless strings , then I used this method :
private Image Base64StringToImage(string base64ImageString)
{
byte[] b;
b = Convert.FromBase64String(base64ImageString);
MemoryStream ms = new System.IO.MemoryStream(b);
Image img = System.Drawing.Image.FromStream(ms);
return img;
}
But this Exception occurred :
Invalid length for a Base-64 char array
Can you help me ?
Sorry for my English. I'm a freshman .
|
|
|
|
|
Works for me with the string given (it's a 16x16 icon with the red mozilla dragon head). Maybe you accidentally include some carriage returns or line feeds in the base64 string?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Wow, yes, you're right.
But I several times tested it. it didn't work.
But now it's working .
Sorry for my English. I'm a freshman .
|
|
|
|
|
HI,
I create some thread and i want to stop one of them.
I don't want to use Abort method.
Is there is some other way to terminate the tread ?
|
|
|
|
|
The best way is to tell the thread to stop itself. Put a volatile boolean varable in the class for the thread. Make the thread check the value of the boolean regularly, so that it can exit when the value changes.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Let take For Example :
private void OnClockStart()
{
while (ClockTick)
{
this.Invoke(clockHandler);
Thread.Sleep(1000);
}
clockThread.Abort();
}
ClockTick = Bool To Check & When u Want to Stop The Thread You Just Assgin False
the While Will break and The clockThread.Abort(); Method will Execute
Have Fun
Never forget it
|
|
|
|
|
I think in your example, clockThread.Abort(); is not needed as making "clockTick" false will end the method which will stop the thread. So no need to abort it explicitly.
|
|
|
|
|
You can use a volatile boolean variable, if it is set as false, exit the method. This is the safest way for cancellation. You can call Thread.CurrentThread.Abort() also, aborting from a known location is safe.
|
|
|
|
|
Rather than a boolean, I suggest looking at a ManualResetEvent(). Threads are often in wait states and this allows you to avoid a polling model.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
i am creating a shortcut for google using IWshRuntimeLibrary. My code is like this
shortcut1 = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(@"C:\Google.lnk");
shortcut1.TargetPath = "http://www.google.com";
shortcut1.Description = "Open Google";
shortcut1.IconLocation = "C:\\icon.ico";
it works quite good.
The problem that i have is when i copy it to another system the icon image is not displayed. I know the problem is
shortcut1.IconLocation = "C:\\icon.ico";
where i specify the icon path on the other system it does not exist. One solution is to copy the icon in C drive but i don't need this.
What i need is this there should be no need to copy icon.
Is there any way to do this that i dont have to copy icon just copy the shortcut.
One possibility is to use windows icons but i want to use my own image(icon).
|
|
|
|
|
A shortcut file can not contain an icon, so you have to have it in a separate file. You have to copy the icon file along with the shortcut.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I have some text box ( multi line ) and i need to add 4 lines.
I want to add them in some way that the structure will be same - i mean like this
Somestr123 info1
Somestr456789 info2
.
.
.
So, I want to format each line in some way that i could have same structure.
I know the maximum string Length of each string.
Thanks.
modified on Sunday, June 22, 2008 5:11 AM
|
|
|
|
|
Use tabs '\t' or fill the gaps with spaces and use a monospace font like Lucida Console or Courier New
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks,
But i need to format the string in different way.
The '\t' give me 4 spaces only and cant help me to save the same format.
I looking for some format that can save me the state of the line.
|
|
|
|
|
Spaces + Monospace Font, as I said.
This of course depends on the font the viewer of the data uses, but there's no other way than to use the same string length via spaces and then force the viewer program to use a monospace font.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi,
a ListBox is more suited to show independent lines of text:
- it never needs the concatenation of all text lines
- it knows how to store a collection of objects, not just strings
- it allows for user drawing.
Without user drawing, you would have to choose a non-proportional (=monospace) font
and insert spaces and/or tabs to align columns.
With user drawing (set DrawMode to DrawMode.OwnerDrawFixed), you can draw each line
yourself. If you have stored a small struct (say string col1, string col2), you can
now paint the different columns individually, using whatever color, size, etc you choose.
|
|
|
|
|
Hi.
I'm trying to connect to SQL Server Express using a DSN. The DSN and SSE is set up with Windows NT authentication. I've tried SqlConnection thisConnection = new SqlConnection("DSN=ESGAS;Integrated Security=SSPI;"); but I get an error saying 'dsn' is not a recognised keyword.
Thanks in advance.
The FoZ
|
|
|
|
|
Don't worry I think I've solved it. It seems that the SqlConnection uses its own protocol to connect to the SQL Server as per this[^] article on MSDN.
The FoZ
|
|
|
|
|
Hi,
I'm using a outlook 2007 add-in project. In this project I added a reference to a dll. Somehow I can't make any calls to any of the methods in that dll. I keep getting FileLoadException. I have strong named this assembly. I read in one place that I have to grant trust to that assembly. Any idea how to fix this? After adding strong name I get this error:
A first chance exception of type 'System.IO.FileLoadException' occurred in MyClass.DLL
Could not load file or assembly 'MyClass, Version=1.0.3094.41526, Culture=neutral, PublicKeyToken=52388ff89a43b4bd' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
Thanks
Ben
|
|
|
|
|
Hi All,
I've not used reflection before so this is all really new to me. I have an object that I want to build in some automating dynamic behaviour based on what 'called it'. What's the best way to get the Type name of the calling type in this objects constructor?
Cheers,
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
You could pass it to the constructor for the new object and then use the System.Object.GetType() method to get it's type (of the object that constructed it) and do further processing from there.
There's a bunch of different ways. And it depends on how many "calling" objects you're dealing with.
|
|
|
|