|
Don't bother. The Setup and Deployment projects were killed off in VS2012 anyway so you're going after legacy technology that, lets be honest here, sucked!
You can use any number of other tools that do a better job and are eaier to use, such as Inno Setup, Advanced Installer, InstallShield LE, WiX, ...
|
|
|
|
|
Hi everyone
which one of these way is correct?why?
Matrix m=new Matrix();
Rectangle rect=new Rectangle(0,0,10,10);
PointF[] point=
{
....
};
Warp(point, rect, m, WarpMode.Perspective,0F);
or
Warp(new PointF[]{....}, new CRect(0,10,10,10), new Matrix(), WarpMode.Perspective,0F);
|
|
|
|
|
These are the overloads as defined[^] in the framework;
GraphicsPath.Warp (PointF[], RectangleF)
GraphicsPath.Warp (PointF[], RectangleF, Matrix)
GraphicsPath.Warp (PointF[], RectangleF, Matrix, WarpMode)
GraphicsPath.Warp (PointF[], RectangleF, Matrix, WarpMode, Single)
Did that answer your question?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
No I didnt, I want to know can I use of this code or not?
Warp(new PointF[]{....}, new CRect(0,10,10,10), new Matrix(), WarpMode.Perspective,0F);
|
|
|
|
|
They are both syntactically correct. However, the first option is easier to debug when things start to go wrong.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Thank you Richard.
|
|
|
|
|
I want to keep some of my classes in library files and load them during runtime. I can load the assemblies and everything works fine. However, I don't find any function that will close or unload the assembly after a method is done using the assembly.
If the function is called several times, the assembly loading will be done multiple times. Without any function to unload it, can it cause any problem in application some times?
I'm now beginning the project so I would like to know the right approach and follow it. I would like to know before I start my project as I do not want to face any problems in the middle of the project. Please help and thanks in advance.
|
|
|
|
|
Dan_K wrote: If the function is called several times, the assembly loading will be done multiple times.
Why? Just add in a boolean that's set when it's loaded the first time, and check it before you load the assembly. That way the logic is executed only once, eliminating the need to know how often the assembly is in memory.
FWIW; it's loaded into memory once, and remains there. There's no unloading, unless you put everything in a separate AppDomain.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks! But does the AppDomain check whether it has already been loaded so that it does not load again for consecutive calls? I'm using .net framework 4.0.
|
|
|
|
|
Dan_K wrote: But does the AppDomain check whether it has already been loaded so that it does not load again for consecutive calls?
Dunno, you'd have to check the documentation for that. Just add in the check yourself, it's simply a matter of setting and checking a boolean to avoid the question in the first place - I wouldn't waste time on finding out.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Presumably you are referring to reflection in that you are loading the type yourself.
Per your basic description you should structure your code such that the assembly, and even the class is only loaded once. Once loaded you create instances from that class.
Dan_K wrote: I do not want to face any problems in the middle of the project
Better make sure that you do not need to unload it while the app is running since that is a different problem.
|
|
|
|
|
Dan_K wrote: If the function is called several times, the assembly loading will be done
multiple times
An assembly is only ever loaded once. There is no such thing as unloading it unless 1) you tear down the entire process into which it was loaded or 2) it was loaded into an AppDomain and you tear down the AppDomain.
Really, by trying to load and unload assemblies, you're creating FAR more complexity for your application. What if you unloaded an assembly that your code still needed?? BOOM! Exception! Good luck with this.
|
|
|
|
|
If you have the need for unloading assemblies then you have to load them in a dedicated AppDomain you will create first.
The advantages is that you can kill the newly created AppDomain (unloading assemblies) and other advantage is that if one assembly you load is "rotten" then you are not damaging the primary AppDomain.
The drawback is the only basic option to communicate between appdomain is remoting.
If you are looking for some kind of plug-in mechanism then have a look at ms Managed Extensibility Framework (MEF). You'll find good articles on CP about it.
|
|
|
|
|
Guirec Le Bars wrote: that if one assembly you load is "rotten" then you are not damaging the primary AppDomain.
That is true only to a limited extent. For example a bad assembly could still cause a out of memory error or a VM exit.
|
|
|
|
|
Do you really need to 'load them at runtime' (i.e. dynamically using Assembly.Load)? You only need to do that if you want a plugin based architecture. Simply linking to the DLLs at compile time should be sufficient in most cases.
If you do, you should implement some sort of lazy loading wrapper which loads an assembly only if it needs it. Though I think Assembly.Load probably already does that for you internally (don't quote me on that though).
You can only unload assemblies if they're loaded into separate AppDomains, which has serious implications for communication between modules.
|
|
|
|
|
When I try to click a button programmatically using .performClick() it only works when the button is in the same class
// this works
this.buttonStart.PerformClick();
But if I try to use the perform click outside the class it doesn't work
// this doesn' work
FormCalendarCS FCCS = new FormCalendarCS();
FCCS.buttonStart.PerformClick();
However if I use the following code I can access the button's method as follows, but doesn't click the button:
// this works
FCCS.buttonStart_Click(sender, e);
Why is this so, and how do I click on the button in another class.
I appreciate any help, thanks in advance.
Mihael
|
|
|
|
|
It seems like you have made buttonStart_Click public static in your FormCalendarCS class which is why you can access it (probably not a good idea!), whereas buttonStart is an instance created in the designer of your FormCalendarCS (exactly as it should be, check the contents of the designer.cs file).
Creating a new instance of the form will not get you the original button, just a new one on a new form that you haven't made visible so you will never see it.
First of all, change buttonStart_Click to private void buttonStart_Click(object sender, EventArgs e) , there is no valid reason to have it any other way IMO, and if you have changed it, set the access modifier on buttonStart back to private .
Inside FormCalendarCS create this method:
public void ButtonStartPerformClick()
{
buttonStart.PerformClick();
}
Inside your form where you first show your FormCalendarCS instance, add a field:
private FormCalendarCS formCalendarCS;
Before you show it, save the instance to the field.
formCalendarCS = new FormCalendarCS();
formCalendarCS.Show();
Now whenever you want to perform the click, just call:
formCalendarCS.ButtonStartPerformClick();
If the relationships between your classes/forms are more complex, you will need to route the method call(s) appropriately and you may need to use events too if you need to call back up the chain.
Your problem boils down to not understanding instance vs static objects and methods. These are a fundemental part of any OOP language including C# so I suggest some study on this area.
|
|
|
|
|
Thanks Dave,
I took your advice and did as you suggested, however, the button isn't static but was changed to public. I changed it back to private and accessed the button as you said. I also understand what you mean by a new instance of that class, I seem to forget that as I have did that more than once, only to realize my mistake.
Michael
|
|
|
|
|
I've never found a reason to use PerformClick, ever.
The code you put in the event handler really needs to be moved to it's own method. Then you can call it from the button Click event handler or from any outside caller without even touching the button.
|
|
|
|
|
I've never had a reason to use it either - the only advantage is it actually performs the click and so raises any other handlers attached to the Button 's Click event whereas calling the handling code would not do that.
|
|
|
|
|
MAW30 wrote: it only works when the button is in the same class Also, PerformClick() won't work if the button is disabled.
/ravi
|
|
|
|
|
why i cant store vales in database ???
private void Form8registration_Load(object sender, EventArgs e)
{
conn.Open();
}
private void ExecuteInsert(string empname, string desgination, string emailid, string phone, string skype, string address, string shifttime, string panel)
{
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
using (conn)
{
try
{
SqlCommand cmdd = new SqlCommand();
//cmdd.CommandType = CommandType.StoredProcedure;
cmdd.CommandText = "Insert into registrationn values (@empname,@desgination,@emailid,@phone,@skype,@address,@shifttime,@panel)";
cmdd.CommandType = CommandType.Text;
cmdd.Connection = conn;
// cmdd.Parameters.Add("@empid", SqlDbType.VarChar, 150).Value = textBox7_empid.Text;
cmdd.Parameters.Add("@empname", SqlDbType.VarChar, 150).Value = empname;
cmdd.Parameters.Add("@desgination", SqlDbType.VarChar, 150).Value = desgination;
cmdd.Parameters.Add("@emailid", SqlDbType.VarChar, 150).Value = emailid;
cmdd.Parameters.Add("@phone", SqlDbType.VarChar, 150).Value = phone;
cmdd.Parameters.Add("@skype", SqlDbType.VarChar, 150).Value = skype;
cmdd.Parameters.Add("@address", SqlDbType.VarChar, 150).Value = address;
cmdd.Parameters.Add("@shifttime", SqlDbType.VarChar, 150).Value = shifttime;
cmdd.Parameters.Add("@panel", SqlDbType.VarChar, 150).Value = panel;
SqlParameter p1 = new SqlParameter("@ret", SqlDbType.VarChar, 150);
p1.Direction = ParameterDirection.ReturnValue;
cmdd.ExecuteNonQuery();
cmdd.Dispose();
}
catch (Exception ex)
{
string msg = "insert error ";
msg += ex.Message;
throw new Exception(msg);
}
finally
{
conn.Close();
}
}
}
private void button2_reset_Click(object sender, EventArgs e)
{
Reset();
}
private void Reset()
{
textBox1_add.Text = "";
textBox3_phoneno.Text = "";
textBox4_emailid.Text = "";
textBox5_desgination.Text = "";
textBox6_name.Text = "";
textBox7_empid.Text = "";
comboBox1_shifttime.SelectedText= "";
textBox1_skpid.Text = "";
}
private void button3_cancel_Click(object sender, EventArgs e)
{
Close();
}
private void button1_submit_Click(object sender, EventArgs e)
{
if (radioButton1_employe.Checked == true)
{
ExecuteInsert(textBox6_name.Text, textBox5_desgination.Text, textBox4_emailid.Text, textBox3_phoneno.Text, textBox1_skpid.Text, textBox1_add.Text, comboBox1_shifttime.SelectedItem.ToString(), radioButton1_employe.Checked.ToString());
}
else
{
MessageBox.Show("data not stored ");
}
}
|
|
|
|
|
1 - Use Pre Tag To format your code, and make it readable.
2- In The Catch use
MessageBox.Show ( ex.Message)
So we can know what kind of error you get.
2 - Show me the Your Table Structure and Your Stored Procedure Code.
private void Form8registration_Load(object sender, EventArgs e)
{
conn.Open();
}
private void ExecuteInsert(string empname, string desgination, string emailid, string phone, string skype, string address, string shifttime, string panel)
{
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
using (conn)
{
try
{
SqlCommand cmdd = new SqlCommand();
cmdd.CommandText = "Insert into registrationn values (@empname,@desgination,@emailid,@phone,@skype,@address,@shifttime,@panel)";
cmdd.CommandType = CommandType.Text;
cmdd.Connection = conn;
cmdd.Parameters.Add("@empname", SqlDbType.VarChar, 150).Value = empname;
cmdd.Parameters.Add("@desgination", SqlDbType.VarChar, 150).Value = desgination;
cmdd.Parameters.Add("@emailid", SqlDbType.VarChar, 150).Value = emailid;
cmdd.Parameters.Add("@phone", SqlDbType.VarChar, 150).Value = phone;
cmdd.Parameters.Add("@skype", SqlDbType.VarChar, 150).Value = skype;
cmdd.Parameters.Add("@address", SqlDbType.VarChar, 150).Value = address;
cmdd.Parameters.Add("@shifttime", SqlDbType.VarChar, 150).Value = shifttime;
cmdd.Parameters.Add("@panel", SqlDbType.VarChar, 150).Value = panel;
SqlParameter p1 = new SqlParameter("@ret", SqlDbType.VarChar, 150);
p1.Direction = ParameterDirection.ReturnValue;
cmdd.ExecuteNonQuery();
cmdd.Dispose();
}
catch (Exception ex)
{
string msg = "insert error ";
msg += ex.Message;
throw new Exception(msg);
}
finally
{
conn.Close();
}
}
}
private void button2_reset_Click(object sender, EventArgs e)
{
Reset();
}
private void Reset()
{
textBox1_add.Text = "";
textBox3_phoneno.Text = "";
textBox4_emailid.Text = "";
textBox5_desgination.Text = "";
textBox6_name.Text = "";
textBox7_empid.Text = "";
comboBox1_shifttime.SelectedText= "";
textBox1_skpid.Text = "";
}
private void button3_cancel_Click(object sender, EventArgs e)
{
Close();
}
private void button1_submit_Click(object sender, EventArgs e)
{
if (radioButton1_employe.Checked == true)
{
ExecuteInsert(textBox6_name.Text, textBox5_desgination.Text, textBox4_emailid.Text, textBox3_phoneno.Text, textBox1_skpid.Text, textBox1_add.Text, comboBox1_shifttime.SelectedItem.ToString(), radioButton1_employe.Checked.ToString());
}
else
{
MessageBox.Show("data not stored ");
}
}
|
|
|
|
|
There is no stored procedure
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
and my stored procedure for the registration form is
ALTER PROCEDURE registrtn
(
@empname varchar(150),
@desgination varchar(150),
@emailid varchar(150),
@phone varchar(150),
@skype varchar(150),
@address varchar(150),
@shifttime varchar(150),
@panel varchar(150)
)
As
begin
INSERT INTO registrationn VALUES(@empname,@desgination,@emailid,@phone,@skype,@address,@shifttime,@panel)
select SCOPE_IDENTITY() as empid
end
|
|
|
|
|