|
Hampus@foi wrote: I had obviously overlooked that information.
Just think of me as Helps help
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
led mike
|
|
|
|
|
This is probably something simple for those in "the know" but I'm not
part of this exclusive group. So any help would be very appreciated.
Any idea why this code:
public override void LoadData()<br />
{<br />
base.LoadData();<br />
if (!this.Page.IsPostBack) <br />
{<br />
ArrayList list;<br />
if ((DataSource == null))<br />
{<br />
list = new ArrayList();<br />
}<br />
else<br />
{<br />
list = new ArrayList(this.DataSource); <br />
<br />
}<br />
int i;<br />
for (i = 0; i < 50; i++)<br />
{<br />
list.Add(new LineScheduleRecord()); <br />
<br />
} <br />
this.DataSource = (LineScheduleRecord[])(list.ToArray(typeof(LineScheduleRecord)));<br />
}<br />
}
Would produce this error:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0029: Cannot implicitly convert type 'LINESCHEDULER.Business.LineScheduleRecord[]' to 'LINESCHEDULER.Business.LineScheduleAdminRecord[]'
Source Error:
Line 367: // list.Insert(i, new LineScheduleRecord());
Line 368: }
Line 369: this.DataSource = (LineScheduleRecord[])(list.ToArray(typeof(LineScheduleRecord)));
Line 370: }
Line 371:}
Check out my 7 Part Series on Networking[^]
Spyware Giving You Fits? Read My Latest Article.[^]
Welcome to the CodeProject!- أهلاً بكم في كود بروجكت
- Καλώς ήλθες στο τόπο τωνκοδικων - സീപിയിലേക്കൂ സ്വാഗതം - コード·プロジェクトへようこそ - Добро пожаловатьна - كوڈ ڀراجيكٹ ميں خوش آمديد - ಸೀಪೀ" ಗೆ ಸ್ವಾಗತ
|
|
|
|
|
it would appear that the error is in the error
Cannot implicitly convert type 'LINESCHEDULER.Business.LineScheduleRecord[]' to 'LINESCHEDULER.Business.LineScheduleAdminRecord[]'
the cast is wrong. perhaps you should have something like this:
this.DataSource = (LineScheduleAdminRecord[])(list.ToArray(typeof(LineScheduleRecord)));
regards,
g00fy
|
|
|
|
|
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!
|
|
|
|