|
It's new information for me. Can you tell me an example for the optimizations done ? I have checked our applications with reflector and can't find any changes in the code.
|
|
|
|
|
Do an If\then\else statement in VB like this:
Dim i As Integer = 3
If i = 1 Then
Console.WriteLine "1"
ElseIf i = 2 Then
Console.WriteLine "2"
ElseIf i = 3 Then
Console.WriteLine "3"
EndIf
You will most likely see that it gets shown to you in Reflector as a case statement.
Things like that...
|
|
|
|
|
Interesting. It shows case statement like
Select Case 3
Case 1
Console.WriteLine("1")
Exit Select
Case 2
Console.WriteLine("2")
Exit Select
Case 3
Console.WriteLine("3")
Exit Select
End Select Compiler changed the code. But the case statement generated looks bad, isn't it ? In this case why don't compiler generate something like Console.WriteLine("3") alone since it knows only 3 will be printed. I am just wondering
I tried slightly altered below code
Dim i As Integer = 3
If (i = 1) Then
Console.WriteLine("1")
ElseIf (i = 2) Then
Console.WriteLine("2")
ElseIf (i = 3) Then
Console.WriteLine("3")
Else
Console.WriteLine("none of them")
End If
Console.Read This will be compiled as it is. No changes are made.
Thanks for clearing doubt.
|
|
|
|
|
Remember though, the compiler did not really change the code, it just built the underlying IL in a way that when Reflector reversed it this is how it was structured.
Not sure if I agree that the case statement is worse or better than the if statement really although I question the real need for the Exit Select parts there.
If you change the if statement to take into account multiple conditions like this:
Dim i As Integer = 3
Dim test As Boolean = True
If (i=1) And (test = True) Then
You will see that Reflector keeps this as an If statement. Have not looked at the resulting IL closely but I just suspect that the IL for the first If is better (more efficient) coded as a case than an IF (maybe less tests?) and as you add conditions that efficiency looses it's value so it is built differently. I am not a compiler expert so I can't say for sure there.
|
|
|
|
|
The CodeProject occasionally gives out the Spices Obfuscator in the article competitions and it can be used to scramble the assembly to make it 'harder' for others to crack it.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
VS.Net ships with Dotfuscator Community Edition.
Look in your Tools menu.
|
|
|
|
|
Hi
Iam doing windows application using c#..
when i build the application...it's sucessfully build..
and run the application (Ctrl+f5) with out debugging mode..
it's giving error---
system.InvalidoperationException occured in .exe[3660].Just-in-time debuging exception failed..
but when i run the application in Debugging Mode F5 it's working Fine...
I think the problem is in my
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
mainform form = mainform.GetInstance();
Application.Run(form);
}
please give me solution where the exact problem is ?
murali krishna
|
|
|
|
|
Without knowing what are you doing in mainform we can't help.
|
|
|
|
|
hi there,
i developed a complex windows form application which contains a lot of controls (textbox, combobox). I use following code, when i've to change their text properties:
this.mytextbox.text = "smth";
considering that i've more than 50 textboxes and comboboxes, i'd like to know if there is another way to write down more efficient and structured code.
I was thinking about using a pattern (i remember to have read in codeproject something like that, but i still haven't found the article).
best regards.
|
|
|
|
|
hi
search in www.codersource.net [^]
u have to write a loop which iterates to all the controls in that form and according to your requirement change that control text .
|
|
|
|
|
hi all,
i developed one windows application which needs database interaction . now i want to deploy the application in the client system which dont have .net and database .
i know how to install .net framework component but which database component i want to install to run the database .im using sql 2005.
can u please explain me the procedure ...
thanks .
CSN
|
|
|
|
|
Depends on the app. The simplest thing I've found is to write an app that runs the installation scripts against the DB. You can also ship a DB backup and expect the user to restore it. I'm sure there are other ways, but the question is, how technical are your end users ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
First of all, is there any Sql server installed? Or which dbms are you using?
|
|
|
|
|
hi ,
thanks for ur reply . here in client system he dont have any database
i have to do all the things .
i dont know whether to install full version of sql server 2005 or sql server express 2005 . is sqlexpress2005 is sufficient ???
can u tell which is better one to do ..
thanks .
CSN
|
|
|
|
|
That depends on the client needs. You should check the differences between the express edition and the full version.
Also keep in mind that while the express edition is free, the full version is not. I never agree to install any pirated software to any client, it's not fair and you too could be held liable.
|
|
|
|
|
Im implementing a currency converter into an application of mine. The data i need to read from is stored in the file CurrRates.txt and is comma delimited. I am trying to set it up so that I open the file, read each line and send that line to an array, then read the next line etc, then closes the file.
As I am trying to learn all this ive spent ages looking for what is necessary, and so far all I have determined is that it usese FileStream. Ive spent along time trying to implement it but my knowledge is limited as, like i said, im still learning.
Any help would be appreciated.
|
|
|
|
|
File.ReadAllLines will do what you want.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Heres what I have so far:
private void importRates()
{
string[] line;
System.IO.FileStream fStream = new FileStream("C:\\UserData\\Rossulator\\CurrRates.txt", FileMode.Open);
while (fStream != null)
{
// add line to array
}
}
I tried File.ReadAllLines and I either didn't understand or didn't put it in the right place...probably both.
|
|
|
|
|
Okay let me rephrase my question cos im not making sense.
I originaly had:
private void importRates()
{
rates[0, 0] = 0.010289;
rates[0, 1] = 97.1907;
rates[1, 0] = 1.07181;
rates[1, 1] = 0.933001;
rates[2, 0] = 1.67566;
// etc to rates[19, 1] = 0.026708;
}
and everything was working fine. I did this so i could learn how to do it, but also to make sure i had the rest of my code working, which i do. The next step is to take all that rates[19, 1] = 0.026708; stuff, and put it into an external file. I want to read in that file, take each line into an array, and use that instead of having a massive list of information which is very difficult to update regularly.
I hope this clears things up a bit.
|
|
|
|
|
System.IO.File.ReadAllLines(filename)
will read an entire file line by line into a string array.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks for your help, finally got it, even though i ended up using ReadLine();. The only reason i looked around for something else was because intelli-sense wasn't showing it as an option :/. Anyway, thought id post my final code, just cos.
private void importRates(){
string path = Settings.Default.FileName;
if (!File.Exists(path))
{
MessageBox.Show("no file found at " + path);
return;
}
int lineCount = 0;
StreamReader sr = new StreamReader(path);
{
String line;
while ((line = sr.ReadLine()) != null)
{
string[] ToFrom = line.Split(',') ;
rates[lineCount, 0] = double.Parse(ToFrom[0]);
rates[lineCount, 1] = double.Parse(ToFrom[1]);
lineCount++;
}
sr.Close();
}
}
|
|
|
|
|
File.ReadAlllLines is the better option IF you are doing this on the standard framework and not the compact framework, because the compact framework doesn't contain this method.
If you are on the compact framework the above code isn't a good implementation of the StreamReader object, you should use a tryf statement or the simplier method of a using statement to the StreamReader object to finalize after execution.
Below is better (with the using statement) though you might want to check for End of File and other sorts also (which have not been added by me)
private void importRates()
{
string path = Settings.Default.FileName;
if (!File.Exists(path))
{
MessageBox.Show("no file found at " + path);
return;
}
int lineCount = 0;
using (StreamReader sr = new StreamReader(path))
{
String line;
while ((line = sr.ReadLine()) != null)
{
string[] ToFrom = line.Split(',');
rates[lineCount, 0] = double.Parse(ToFrom[0]);
rates[lineCount, 1] = double.Parse(ToFrom[1]);
lineCount++;
}
sr.Close();
}
}
|
|
|
|
|
I am looking for some good quality skins for a Windows Forms project.
The software is going to be a Winforms app that will be used in conjunction with iTunes/iPhone so I would like the GUI to look more polished than a plain vanilla out-of-the box Winforms app.
What in your opinion are the best free skins currently available?
|
|
|
|
|
Your basic problem is that winforms do not support skinning without some library to do it for you.
Does the iPhone even run .NET ? I'd be astounded if it did.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I've seen some demos of running Mono on the iPhone
|
|
|
|