|
code-frog wrote: this.DataSource = (LineScheduleRecord[])(list.ToArray(typeof(LineScheduleRecord)));
What's the type of this.DataSource ? If it's LineScheduleAdminRecord[], then it looks like it's a cast problem. Of course, that's assuming list has LineScheduleAdminRecord instances.
|
|
|
|
|
This is actually a bug in Iron Speed Designer. I'm working with their support on it. Thank you though.
|
|
|
|
|
Hi All
I am writing a .net windows app that should also run from command line. I am not sure what is the best way to set such a project.
I intend to create a windows project and on the Sub Main rotine check if any arguments are passed. If not run a form.
Public Shared Sub Main(ByVal Params() As String)<br />
If Params.Length = 0 Then<br />
'run windows mode<br />
Application.Run(frmMain)<br />
else<br />
'run console application<br />
some code<br />
End If<br />
End Sub
Would this be the best way or is there any standard way of doing this ?
Many Thanks
Mustafa
www.hostukdomain.com
|
|
|
|
|
yes, thats the way to go. i guess thats the "standard" way too
|
|
|
|
|
Probably:
public static void Main(string[] args)
{
if (args.Length == 0)
{
Application.Run(new MainForm());
}
else
{
}
}
(NOTE: This is the C# forum)
|
|
|
|
|
Hello
I was wondering for some time about the difference between your approach -ie. main(string[] args) - and using Environment.GetCommandLineArgs() method to get the CommandLine arguments? Do you know which is better and why?
Regards
|
|
|
|
|
Nader Elshehabi wrote: Do you know which is better and why?
Neither is better.
It all depends on where in the application you are. If you don't store in the information in your Main() method, you can always get it from Environment.GetCommandLineArgs();
|
|
|
|
|
One problem guys.
I cannot get the console screen
The project needs to be setup as windows. (cannot setup as console type
when I write following
public static void Main(string[] args)<br />
{ <br />
if (args.Length == 0) <br />
{ Application.Run(new MainForm()); <br />
} <br />
else<br />
{
Console.Write("Hello");<br />
}<br />
}
thanks
Mustafa
www.hostukdomain.com
|
|
|
|
|
Surely that is just for debugging? No? When you run the application at a real command prompt it should work? (I don't have Visual Studio in front of me right now so I cannot test this)
|
|
|
|
|
|
Hello
i am devloping an application.
but how can i search for a file
|
|
|
|
|
hi,
Use FileInfo or DirectoryInfo class in System.IO namespace.
I think now you have got the hint,use this....and reply me
nishu
|
|
|
|
|
You could search for files by writing a recursive function.
The function has one parameter - DirectoryInfo dirToCrawl - which lets the function know where to search.
<br />
public void SearchFile(DirectoryInfo dirToCrawl, string Filename)<br />
{<br />
DirectoryInfo [] subdirs = dirToCrawl.GetDirectories();<br />
FileInfo [] filesInDir = dirToCrawl.GetFiles();<br />
for (int i = 0; i < subdirs.GetLength(0) - 1; i++)<br />
{<br />
SearchFile(subdirs[i], Filename)<br />
}<br />
for (int i = 0; i < filesInDir.GetLength(0) - 1; i++)<br />
{<br />
if (filesInDir[i].Name == Filename)<br />
{<br />
}<br />
}<br />
}<br />
If you would call the function like
<br />
DirectoryInfo mysearchroot = new DirectoryInfo("C:\\");<br />
SearchFile(mysearchroot, "foo.txt");<br />
it would search all directories and subdirectories of C: for "foo.txt"...
Hope it helps,
mik
|
|
|
|
|
See an example here:
http://www.codeproject.com/cs/files/winsearchfile.asp
Utkarshraj Atmaram
|
|
|
|
|
I am using a DLL written in C in my C# project.
The original C function goes like this:
char* SomeFunction(const SomeClass someObj, const void* ptr, char* str, size_t strSize);
The value of str is changed in the function. This is how I've written in C# interop file:
Using size_t = System.UInt32;
...
...
[DllImport(DLLNAME)]
public static extern string SomeFunction(SomeClass someObj, IntPtr ptr, ref string str, size_t strSize);
While calling the function in C#, I am passing some uint value such as 1024 in place of strSize.
I am getting FatalExecutionEngineError on running the code:
Message: The runtime has encountered a fatal error.
The address of the error was at 0x79ef067e, on thread 0xfb8.
The error code is 0xc0000005.
This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code.
Common sources of this bug include user marshaling errors
for COM-interop or PInvoke, which may corrupt the stack.
I have two more functions with parameters as char* in C, and ref string in C#. The program simply terminates after the control comes to these functions.
I am wondering if there is something wrong with char* and ref string ?
-- modified at 10:05 Wednesday 6th September, 2006
Ut
|
|
|
|
|
Did you try to leave it as a normal string (without ref)?
I noticed that trying to get the memory address of a "managed" type and assigning it to a pointer will result in an exception because the compiler don't wants to.
Maybe this is the cause for your error though i don't know how this stuff works (by this stuff i mean interop and the whole com )
|
|
|
|
|
[DllImport(DLLNAME)]
public static extern string SomeFunction(SomeClass someObj, IntPtr ptr, System.Text.StringBuilder str, size_t strSize);
|
|
|
|
|
Thanks Judah! That worked!
Ut
|
|
|
|
|
is there a way to set a stastic library in c# programs like vc++ to be able to run a c#.net application on a system that has not dotnet framwork?
excuse me for my poor engelish I'm trying to learn
|
|
|
|
|
Afaik there is no possibility like that :P
You still would have to translate the IL-Code which is produced by the c# compiler to real machine instructions (guess asm ) That's why you ALWAYS need the .Net Runtime.
Maybe that has changed now so keep on googling :P
|
|
|
|
|
Hello
To make you .Net application run without the need of .Net framework, you need something like Xenocode Postbuild[^].
Regards
|
|
|
|
|
Hi,
How can i make a textbox accepting only int's and if anything else being typed ignoring it (expect a . (dot)).
Thanks in advance!
|
|
|
|
|
There are several possibilities - In case of .net 2.0 there are so called "masked textboxes" - google for it and you will find nice instructions.
You also could add an eventhandler to your textboxs OnKeyDown event and check if the char (i guess its the "KeyChar" property of the event object which is passed to the eventhandler) is an integer. if it isn't, you will have to set the event objects property "IsHandled" or "Handled" or somewhat like that to true.
This will prevent the Char from being entered in the textbox...
|
|
|
|
|
Hi,
Thank you for your reply!
Ima google that up!
|
|
|
|
|
hi, try this:
private void textBox1_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e)
{
int intKeyValue = (int)e.KeyChar;
if (((intKeyValue<48 || intKeyValue>57 ) && intKeyValue!=46))
{
e.Handled = true;
}
}
you can add any extra chars valus, just like 46(dot), you can 8(backspace)
Tamimi - Code
|
|
|
|