|
Hi everybody.
I have migrated my software from VS2005 to VS2010, and when debugging my windows services, trying to attach to the process I get this error:
"Unable to attach to the process. Visual Studio has insufficient privileges to debug this process. To debug this process, Visual Studio must be run as an administrator."
So, I run it as an administrator, I checked the permission on VSLauncher.exe and devenv.exe to make it run always as an admin, but I still get the error.
I am an administrator already. Has anybody have this same problem?
BTW, I'm using W7, VS2010.
|
|
|
|
|
Did you try Opening the application as with Run as Administrator? And does the service also run in the same account ?
Sastry
|
|
|
|
|
Thanks for your answer Sastry.
Yes, I tried selecting the box "Run as administrator" on the Visual Studio launcher, and also tried with right click -> Run as administrator. The top of the window says "Visual Studio 2010 (Administrator)" . And the service is running in my user.
I don't know why is this still happening. Any other idea?
First I thought that the problem was to try to debug the code on the network, but I also copied the solution to my C: and it still happens.
|
|
|
|
|
It was a permissions problem.
Win7 comes with a new security system, and I had to add to my profile (even being an admin) this permission:
Control panel -> Administrative tools -> Local Security policy -> Local Policies -> User rights Assignment -> Debug programs -> Add user or group .
And there, I added my own user. Reboot machine(Important!! Without rebooting, it won't work).
After that, I was able to attach processes to debug them. It's been a really long time to solve this, I hope to help other people that find this same problem.
Thanks everybody for your help.
|
|
|
|
|
Hi,
I have created a database inside the windows application project.Now i am trying to insert data into that database 'database.mdf'.But data are not inserted as well as not showing error also.But same code is working for inserting data in database which one i created outside the visual studio using sql server management tool.Why is the problem?
|
|
|
|
|
may be your sql command query problem!!! show me your code then i may help u ![Smile | :)](https://codeproject.freetls.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
|
If you want help then post any further information here, so it is available for everyone to see. Do not try to create private message threads.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
Debug through your source code, pick up the query from the code and then run it in SQL Server management studio.
This should give you a fair idea of what you might be doing wrong with the query.
|
|
|
|
|
|
Harsha Dev wrote: xxxx@gmail.com
I would recommend you remove your email id to avoid being hit by tons of spam.
|
|
|
|
|
ok abhinav i will remove... thanks ![Smile | :)](https://codeproject.freetls.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
set the "copy to output directory" property of the database file within visual studio to "Copy if newer", visual studio copies your database to the output directory whenever you build your solution, because of this, if you run your application and insert some data, when you run it again, your database will be copied again to the output directory and you will lose your data. to test without changing properties, go to your project folder, inside the /bin/Debug folder and start your app from here. your data should be here on the second run.
sorry for my english, i expect that you can understand.
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
this is my array variable,
int[] x = null;
x = new int[10];
int[] y = null;
y = new int[10];
and this is my random function,
private int Randomize(int MinValue, int MaxValue)
{
Random Random = new Random();
return Random.Next(MinValue, MaxValue);
}
this is how i random all of that variable,
for (int i = 0; i < 10; i++)
{
x[i] = Randomize(1, 60);
y[i] = Randomize(1, 10);
}
and the result is,
x[0] = 42 y[0] = 3
x[1] = 42 y[1] = 3
x[2] = 42 y[2] = 3
x[3] = 42 y[3] = 3
x[4] = 42 y[4] = 3
x[5] = 42 y[5] = 3
x[6] = 42 y[6] = 3
x[7] = 42 y[7] = 3
x[8] = 42 y[8] = 3
x[9] = 42 y[9] = 3
am i missing something in my random function?
i've searched it in google and still found Random.Next()
** MODIFIED
i found out in google that Random.Next generating same value because I execute it at the same time.
so i put like this,
private int Randomize(int MinValue, int MaxValue)
{
Thread.Sleep(100);
Random Random = new Random();
return Random.Next(MinValue, MaxValue);
}
nah this time the value disorder epicly,
but yes i have to wait,
keep searching for other way,
and please someone help me.
Thanks before,
VK
modified 19-Apr-12 0:13am.
|
|
|
|
|
AFAIK you only need to instantiate the Random class once, outside your loop, then in your loop you can call Random.Next(). Also try seeding it with DateTime.Now.
|
|
|
|
|
int[] x = new int[10];
int[] y = new int[10];
Random r = new Random();
for (int i = 0; i < 10; i++)
{
x[i] = Randomize(r, 1, 60);
y[i] = Randomize(r, 1, 10);
}
private int Randomize(Random r, int minValue, int maxValue)
{
return r.Next(minValue, maxValue);
}
should do the trick.
Not only will it ensure that you get (pseudo)random integer series, but also it will execute faster since you don't create a new Random everytime you call the Randomize() method.
No memory stick has been harmed during establishment of this signature.
|
|
|
|
|
good topic ![Smile | :)](https://codeproject.freetls.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
hey guys does any one have a simple source code to create a really simple memory leak?
|
|
|
|
|
Use an unmanaged resource and dont dispose it. This will create a possible form of memory leak.
|
|
|
|
|
My vote of 5 for to the point answer
Happy Coding...
|
|
|
|
|
|
|
thanks VJ
Happy Coding...
|
|
|
|
|
Greetings,
I wanna make a form that is used to search for something in a database and I wanna make it as a general search from, means I wanna use it with all project forms each one appear different data and dealing with different table in the database, this is not the case, the case is, I will call that search form from another one. I made a constructour which take 3 arguments when called that define the table name on which the search will be made the selection/condition columns in that search form so when I make an instance from another form I pass to that instance the specified arguments and on the search form I made fields that are of the same type as the arguments so when the instance is made it initialize those fields which will be used by the method of search when that form comes in action. I wanna provide the user with options to search by name or by code and of course, with each choice the selection/condition columns will be changed one with the other, and this is my case now. For example, I have a form that displays, saves, deletes records of resources in the factory I will, when clicking mouse right button, make a search form instance.
(searchform) [instance] = new searchform(argTable, argSelectionCol, argConditionCol);
call the search form [instance].show();
So I will give it the table but in the search form itself I wanna make a code/name selection choice for searching process and that will not apply as I already passed, when I made the instance, the selection/condition column.
I wanna know how to made such form and if anyone have another better way/idea about makng such search form based on my requirement I described above I will be grateful for that
Sorry about so lengthy ![Smile | :)](https://www.codeproject.com/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
This is my search form code if any one have a better way to tell it to me.
Note: There might be some arabic words clearly show in MessageBox.Show() methods
public partial class FrmFind : Form
{
string seacrhChoice = "";
// Create a Connection String
string connectionString = @"Data Source=TOSHIBA-PC;Initial Catalog=smart2012;User ID=sa;
Password=Str0ngP@ssw0rd;Integrated Security=True";
private string tableName;
private string returnTableField
{
set { tableName = value; }
get { return tableName; }
}
private string column1;
private string returnColumn1
{
set { column1 = value; }
get { return column1; }
}
private string column2;
private string returnColumn2
{
set { column2 = value; }
get { return column2; }
}
public FrmFind()
{
InitializeComponent();
}
public FrmFind(string table, string argColumn1, string argColumn2)
{
InitializeComponent();
returnTableField = table;
returnColumn1 = argColumn1;
returnColumn2 = argColumn2;
} // end of 3 args constructor
bool validateUserEntry()
{
if (seacrhChoice == "")
{
MessageBox.Show("من فضلك اختر احدى اختيارات البحث");
radioButton1.Focus();
return false;
} // end of if
else if (findValueTextBox.Text.ToString().Trim() == "")
{
MessageBox.Show("من فضلك ادخل قيمة البحث المراد الأستعلام عنها");
findValueTextBox.Focus();
return false;
} // end of esle if
else
{
return true;
} // end of else
}
void search(string findValue)
{
bool validateUserEntryResult = validateUserEntry();
if(validateUserEntryResult == true)
{
string cmdString = "";
// Creat new Connection
SqlConnection sqlConnection = new SqlConnection();
sqlConnection.ConnectionString = connectionString;
if (seacrhChoice == "كود")
cmdString = @"SELECT " + returnColumn2 + " FROM " + returnTableField + " WHERE (" + returnColumn1 + "=@Param1)";
else
cmdString = @"SELECT " + returnColumn1 + " FROM " + returnTableField + " WHERE (" + returnColumn2 + "=@Param1)";
// Create the SELECT Command.
SqlCommand cmd = new SqlCommand();
cmd.CommandText = cmdString;
cmd.Connection = sqlConnection;
if (seacrhChoice == "كود")
cmd.Parameters.Add("@Param1", SqlDbType.Int).Value = findValue;
else
cmd.Parameters.Add("@Param1", SqlDbType.NVarChar).Value = findValue;
try
{
// Open Connection
sqlConnection.Open();
if (sqlConnection.State != ConnectionState.Open)
{
MessageBox.Show("فشل فى الأتصال بقاعدة البيانات");
} // end of if
else
{
findResultDataGridView.Rows.Clear();
findResultDataGridView.Rows.Add(99);
SqlDataReader dataReader = cmd.ExecuteReader();
int row = 0;
// Execute Read Query
while (dataReader.Read())
{
findResultDataGridView[0, row].Value = dataReader[0].ToString();
row++;
}
// Release all resources used by dataReader and close it.
dataReader.Dispose();
dataReader.Close();
// Close Connection
sqlConnection.Close();
sqlConnection.Dispose();
} // end of else
} // end of try
catch
{
findValueTextBox.Text = "";
} // end of catch
} // end of if
} // end of search()
private void findValueTextBox_Leave(object sender, EventArgs e)
{
search(findValueTextBox.Text);
} // end of findValueTextBox_Leave
private void radioButton1_Click(object sender, EventArgs e)
{
seacrhChoice = "كود";
findValueTextBox.Text = "";
findResultDataGridView.Rows.Clear();
findValueTextBox.ReadOnly = false;
} // end of radioButton1_Click
private void radioButton2_Click(object sender, EventArgs e)
{
seacrhChoice = "اسم";
findValueTextBox.Text = "";
findResultDataGridView.Rows.Clear();
findValueTextBox.ReadOnly = false;
} // end of radioButton2_Click
private void FrmFind_Load(object sender, EventArgs e)
{
// Creates and initializes the CultureInfo which uses the international sort.
System.Globalization.CultureInfo typeOFLanguage = new System.Globalization.CultureInfo("ar-eg");
// Gets the current input language
InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(typeOFLanguage);
findResultDataGridView.Rows.Add(99);
} // end of FrmFind_Load
} // end of public partial class FrmFind : Form
2 problems I have also in that form:
The search method checks for a radio button selection & a search value insertion so first problem is by calling the method validateUserEntry(), however, here comes the problem on the form load the textbox always gets focused and when trying to check a radio button that cause a leave event to the textbox which mean calling the search method which, in turn, call the validateUserEntry() and here is the disaster as I did not select the radio button it message me with error because of not selecting a radio button, and return message me again asking for the search value of the textbox.
Sorry again about so lenghty but trying to explain exactly what the problem is...
|
|
|
|
|