|
anyone who can give me one simple but good example to demonstrate that application domain has to be used.
because I found most examples for application domain can not demonstrate clearly that the necessity of application domain.
thanks.
|
|
|
|
|
This [^]might be an answer to your question.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
thanks.
but I still can not find some concret examples. It seems to me most people did not use it often.
this may be the reason that it is hard to find some good practical examples.
|
|
|
|
|
I use an App Domain to load config files into a process and associate it with a DLL. I blogged about a variant of my code here[^].
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Every .NET application will have an application domain associated with it and it will be created automatically. Creating your own application domains helps you when you are dealing with plugin kind of architecture. Each plugin can be loaded on a new application domain and it can work isolated.
If you are familiar with NUnit, they use a new application domain to load the assemblies specified by the user. This will help them to isolate user code execution and proper resource and memory cleanups. When an application domain is unloaded, all the memory associated with it will be cleared.
Hope that makes it clear
|
|
|
|
|
how to implement the nested string case?
such as
string str="MessageBox.Show("hello")";
above code has compiled error anyway.
but how to do then?
thanks.
|
|
|
|
|
"MessageBox.Show(\"hello\")";
|
|
|
|
|
string str = "hello";
messagebox.show(str);
|
|
|
|
|
char quote = '"';
string str = "MessageBox.Show(" + quote + "hello" + quote + ")";
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
I'm getting the following error when i unlock my machine after few minutes. i have run my application before lock the machine.
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Windows.Forms.SafeNativeMethods.MessageBox(HandleRef hWnd, String text, String caption, Int32 type)
at System.Windows.Forms.MessageBox.ShowCore(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, Boolean showHelp)
at System.Windows.Forms.MessageBox.Show(String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon)
at SampleApplication.FormExportData.toolStripNewExport_Click(Object sender, EventArgs e)
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
I don't know the reason for this error. Any knows the reason?
Thanks in advance 
|
|
|
|
|
Hello Guys,
I have an issue with Deserialization. I have 2 Projects and I want to extport data to a binary file (serialize) in the first Project, and i want to read that date using the second application Deserialize.
The first Aplication will be given to hte end user, and will generate a Binary file that i want to read using the Admin application (the second one).
When i try to deserialize i receive this error:
"Unable to find assembly 'Application Timing', Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."
I think i know the cause of the issue. The binary formatter puts the Application name,version and info in the file when it serilizes it, but i don't know how to bypass this.
Any suggestions?
Kind regards,
Alex
“Be the change you want to see in the world.”
|
|
|
|
|
There are two options:
1. Put the class definition in a separate assembly and deploy it in both applications
2. Use SerializationBinder. Here is an example: Draw with Mouse[^]
|
|
|
|
|
Hi all,
Using C#, is it possible to handshake a certain remote port using only the first two steps (SYN -> SYN-ACK), and then cut-off the connection without the final third step (ACK)?
The requirement is NOT to send the ACK, and as far as I understand, the Connect method of the Socket, handles all the 3 steps handshake automaticaly.
So is there a way to, somehow, stop after the first two steps?
Thanks in advance,
Danny
|
|
|
|
|
Hi
I have a WebBrowser control in my form and I would like it not to show/download images, because I want to stop wasting bandwidth.
Thanks.
|
|
|
|
|
I guess following code would work for you:
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
for (int i = 0; i < this.webBrowser1.Document.Images.Count; i++)
{
this.webBrowser1.Document.Images[i].Style = "display:none;";
}
}
|
|
|
|
|
Can someone explain how to develop a program that capture keystrokes and write them to a log file or text file? Like a keystroke monitor program.
Dushan Perera
|
|
|
|
|
|
You're making a key-logger, therefore you're unlikely to get any help here.
If at first you don't succeed, you're not Chuck Norris.
|
|
|
|
|
Do you know it is illegal to use a key logger to monitor another persons activity on a computer?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Pish posh now.
It's only illegal if you get caught of leave traces of that it is your keylogger.. like leaving messages on a message boar...
|
|
|
|
|
Hi Experts
I had made setup on my PC.I wanted to run that setup on my clients PC without making changes in connectionstring and without attaching to SQL SERVER 2005...
I wanted that my log and mdf files should automatically take path of database.I have kept both the files in my debug folder.
|
|
|
|
|
Would better if you can provide a bit more. Anyway, why you have kept the files in Debug folder.When you prepare your final build, it should be in release mode which you can consider as your application directory.So try to code keeping relative path in mind and which you can store in your config file.
Same is applicable for your connection string which you should be keeping in your config file.Please visit this link.[^].
|
|
|
|
|
Iam Trying to Insert Array values in the database , but first value get inserted but when my loop increments and try to insert the second value iam getting the Error "exSql = {"The variable name '@BezierCusp' has already been declared. Variable names must be unique within a query batch or stored procedure."}Please help me out where iam wrong
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=localhost;Initial Catalog=InkDb;Integrated Security=True;
Persist Security Info=True;Packet Size=4096";
string qry = "Insert into beziertable values(@strokeIndex,@cuspIndex,@BezierCusp)";
SqlCommand sqlInsertCmd = new SqlCommand(qry, con);
sqlInsertCmd.CommandText = qry;
sqlInsertCmd.CommandType = CommandType.Text;
int count;
int i;
sqlInsertCmd.Parameters.AddWithValue("@strokeIndex", mInkoverlay.Ink.Strokes.IndexOf(stroke));
int cus;
cus = Convert.ToInt16(stroke.BezierCusps.GetValue(0));
sqlInsertCmd.Parameters.AddWithValue("@cuspIndex", cus);
//Using loop to get the all stroke.GetPoint , it will return Array(2dimension) , i want to add all values of array
//In the Database In the parameter Bezier Cusp ,but it show me the error that"exSql = {"The variable name '@BezierCusp' has already been declared. Variable names must be unique within a query batch or stored procedure."}
for (i = 0; i <= 100; i = i + 1)
{
val=stroke.GetPoint(i).X;
sqlInsertCmd.Parameters.AddWithValue("@BezierCusp",val);
sqlInsertCmd.Connection = con;
SqlDataAdapter sqlDataAdapter3 = new SqlDataAdapter();
sqlDataAdapter3.InsertCommand = sqlInsertCmd;
con.Open();
sqlInsertCmd.ExecuteNonQuery();
con.Close();
}
Iam unable to find out the Reason my table structure should be like this after Inserting
Stroke Index Cusp Index Bezeir Cusp
0 0 1st value of array(X componet)
1 1 2nd value of Array
like this it should insert the Record in this manner
tell me there any wrong logic iam using to insert the array values in database
with regards
Genius
|
|
|
|
|
You should declare the parameters outside the for loop. e.g.
change:
sqlInsertCmd.Parameters.AddWithValue("@BezierCusp",val);
to:
sqlInsertCmd.Parameters.Add("@BezierCusp", SqlDbType.whatever);
and move it outside of the for loop.
Then in its place put
sqlInsertCmd.Parameters["@BezierCusp"].Value = val;
The error message you are getting is really quite accurate, it is simply telling you that you have already declared @BezierCusp and therefore can't do so again. Which is what your code tries to do on every iteration of the loop, after the first one.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks for your Prompt Reply sir
I have made the changes in the code as you have suggested as shown:
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=localhost;Initial Catalog=InkDb;Integrated Security=True;Persist Security Info=True;Packet Size=4096";
string qry = "Insert into beziertable values(@strokeIndex,@cuspIndex,@BezierCusp)";
SqlCommand sqlInsertCmd = new SqlCommand(qry, con);
sqlInsertCmd.CommandText = qry;
sqlInsertCmd.CommandType = CommandType.Text;
int count;
int i;
sqlInsertCmd.Parameters.AddWithValue("@strokeIndex", mInkoverlay.Ink.Strokes.IndexOf(stroke));
int cus;
cus = Convert.ToInt16(stroke.BezierCusps.GetValue(0));
sqlInsertCmd.Parameters.AddWithValue("@cuspIndex", cus);
// I have made the changes by making declaration outside the loop as sqlInsertCmd.Parameters.AddWithValue("@BezierCusp", val);//My loop works acuurate But as my loop execute i<=100 times and it come out of loop and the value which my variable "val" carry will get inserted into the database , but i want all the values of "val" for each iteration till i=0 to i>=100, But the last value of "val" get inserted , i dont want this , i want all the values of array of the Stroke.GetPoint(i).X. Please suggest me the solution to rectify the Problem///
for (i = 0; i <=100 i = i + 1)
{
val=stroke.GetPoint(i).X;
}
sqlInsertCmd.Parameters.AddWithValue("@BezierCusp", val);
//Only last value which i get in "val" after loop completes get Inserted into Database , but i want all the values to be inserted into database , how i can do this please suggest how should i rectify the problem...//
sqlInsertCmd.Connection = con;
SqlDataAdapter sqlDataAdapter3 = new SqlDataAdapter();
sqlDataAdapter3.InsertCommand = sqlInsertCmd;
con.Open();
sqlInsertCmd.ExecuteNonQuery();
con.Close();
Thanks alot sir, waiting for your response
with regards
Genius
|
|
|
|