|
malharone wrote: I tried various BindingFlags option but no luck yet.
BindingFlags.Declared only
I think you can also try see if the methodinfo's declaredtype and reflectedtype is the same.
|
|
|
|
|
Thank you .. that did the trick. It is much better to know the project has ~7,000 methods as opposed to 150,000 methods!
- Malhar
|
|
|
|
|
Hi,
I have to pass a native Struct from my C++ DLL into my C# program.
The problem is that the struct contains a C++ "union" member.
Can someone recommend a good way to marshal the struct into my managed code?
struct NATIVE_STRUCT
{
DWORD Value1;
DWORD Value2;
union
{
STRUCT1 Member1;
STRUCT2 Member2;
} UnionMember;
};
Thanks a lot,
Rich
|
|
|
|
|
Nevermind...I found the answer.
You have to declare the union member as a struct and use various attributes to describe the physical layout of the struct, such as the [FieldOffset()] attribute.
|
|
|
|
|
Troposphere wrote: I found the answer
There are various tricks you can use in marshalling, just as long as the layout stays the same
|
|
|
|
|
I have a C# Windows Forms app, and I want to launch a whole separate application (another .exe file) when the user clicks a button.
What class and method do I use? It should work just like Start -> Run on the Windows Task Bar.
Thanks,
Mark
|
|
|
|
|
You can use the Process class (part of the System.Diagnostics namespace)
using System.Diagnostics;
...
Process.Start("<path to .exe>");
Cheers,
Will H
|
|
|
|
|
I have this number from which I have to read first few number depending on another number. What is the best way to do that.
For example ... NumToread = 3 , number = "4567889465"
answer should newNum = 456
i can do that using for (int i=1;i<=NumToread ;i++)
does any one knows better way ...
As you can say .. I am very new to programming
Thanks
CPP
Thanks
|
|
|
|
|
You should use the String.Substring() method.
int numToRead = 3;<br />
string buf = "123456789";<br />
buf = buf.Substring(0, 3);
|
|
|
|
|
Thanks
Thanks
|
|
|
|
|
hi all!
my problem
i have a project using .NET 2 in vs.net 2005
in a DataSet i have data from an access-db.
the connection string is stored in the Properties.Settings.Default ...
what i want is that i can change the *.mdb file during runtime so that each user of the programm can set its own db file.
does anyone know how i can do this???
|
|
|
|
|
I don't see the probblem.
If the user is running his program on his computer then you can do whatever you want, no?
If you have a web page then simply store the file name in a session or something like that.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
I have a MainForm (MDIParent), a ChildA form and a Child1OfChildA Form. I have a Panel controll on ChildA Form, How can i place Child1OfChildA on this panel controll on ChildA from?
Thanks
|
|
|
|
|
I have a c# program which retrieves registry settings & writes them out to a .reg file for storage on a network so some application settings can easily be restored after an operating system upgrade, etc. Everything was going just fine until I came across a value of type dword.
If I manually export it from the registry, this is how the name and value look.
"Number of Macros"=dword:00000012
The .GetValue method brings the value in as type System.Int32 with a value of 18 (there are 18 macros defined in that app). Is anyone familiar with this dword type and what I would convert Int32 to to get this value of 00000012?
Thanks in advance for any help!
Lara
|
|
|
|
|
The dword type is a 32-bit signed integer on 32-bit systems. The output you are getting from the registry is 0x00000012 which is 18 in hex. The registry stores dword values in hex. You could always do a decimal to hex conversion to convert 18 to its hex value.
Andy
Deus caritas est
|
|
|
|
|
Got it. Excellent. Thanks!
|
|
|
|
|
I get this error when I try to use implement the IEnumerable interface:
Error 1 'generics.GenStack<t>' does not implement interface member 'System.Collections.IEnumerable.GetEnumerator()'. 'generics.GenStack<t>.GetEnumerator()' is either
static, not public, or has the wrong return type.
Here is the code segment:
// Custom Stack - designed to accept class instances only
public class GenStack<t>: IEnumerable<t>
where T : class
{
private T[] stackCollection;
private int count = 0;
// Constructor
public GenStack(int size)
{
stackCollection = new T[size];
}
public IEnumerator<t> GetEnumerator()
{
string totList = "";
for (int i = 0; i < count; i++)
{
yield return stackCollection[i];
totList+= stackCollection[i]+" ";
}
object ob = totList ;
yield return (T)ob;
}
.
.
}
I am implementing the GetEnumerator(), though. Am I missing something?
Thanks in advance
|
|
|
|
|
A little curious by your code snippet. Try:
<code>
public class GenStack<T> : IEnumerable<T> where T:class
{
public GenStack(...) { ... }
public IEnumerator<T> GetEnumerator() { }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { }
}
</code>
-- modified at 16:53 Tuesday 14th February, 2006
|
|
|
|
|
Can someone tell me how exact it is to customize the size of the buttons in the MessageBox control? I am planning to make my MessageBox by inheriting the one in the .net library.
I know there is something to do with the onPaint event handler, but i am not very sure
thx for all your help
|
|
|
|
|
As far as I know you cannot inherit the one in the .NET library since this is simply a wrapper around the Win32 MessageBox functions.
What I have done is to use a CBT hook to hook the MessageBox right before it is displayed, and in the CBT_ACTIVATED I can change/add/delete controls on the MessageBox. You can get the control ids using Spy++ on any MessageBox. There is a lot of interop involved with this but it works fine. You need to learn about CBT hooks and P/Invoke with .NET to make this work.
I hope this helps.
Andy
Deus caritas est
|
|
|
|
|
Why not just create a dialog form that is your own custom MessageBox? You then could use any controls in it you want.
Paul
|
|
|
|
|
Hi:
does dotnet/c# offer any smart and automated ways to preserve user preferences in GUIs such as controls users like to have checked or unchecked?
Thanks, smurfy
|
|
|
|
|
smurfy,
Not sure if .net has the ability, but saving control states in a database may be the way to go, depending on how many controls you are working with.
I hope this helps some,
Paul
|
|
|
|
|
VS2005 does. It saves initial values for just about any aspect of a component (control) in a app.config file, and stores user-specific and machine-specific settings in the application data directory in the appropriate profile directory. You can read, write and save settings anywhere in your application.
Mark
|
|
|
|
|
Cool, learned something new today
Paul
|
|
|
|