|
byte[] arraybyte = System.IO.File.ReadAllBytes("app.exe");
System.AppDomain dom = System.AppDomain.CreateDomain("newDomain");
Assembly assembly = dom.Load(arraybyte);
assembly.EntryPoint.Invoke(null, null);
That calls the Main() method.
|
|
|
|
|
I run this code.
byte[] arraybyte = System.IO.File.ReadAllBytes("app.exe");
System.AppDomain dom = System.AppDomain.CreateDomain("newDomain");
Assembly assembly = dom.Load(arraybyte);
assembly.EntryPoint.Invoke(null, null);
But in line
assembly.EntryPoint.Invoke(null, null);
have runtimeerror:
"TargetInvocationException was unhandled
Exception has been thrown by the target of an invocation."
Please help me!
|
|
|
|
|
Read the exception's InnerException. That'll tell you the actual error.
|
|
|
|
|
My code :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Reflection;
namespace video
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
try
{
byte[] arraybyte = System.IO.File.ReadAllBytes("D:/work/C#/video/video/bin/Debug/zshchita.exe");
System.AppDomain dom = System.AppDomain.CreateDomain("newDomain");
Assembly assembly = dom.Load(arraybyte);
assembly.EntryPoint.Invoke(null, null);
}
catch (Exception e)
{
string st = e.InnerException.ToString();
}
}
}
}
st :
System.InvalidOperationException: SetCompatibleTextRenderingDefault must be called before the first IWin32Window object is created in the application.
at System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(Boolean defaultValue)
at video.Program.Main() in D:\work\C#\video\video\Program.cs:line 16
Program.cs :
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace video
{
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
line 16 Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
???
Please help me!
-- modified at 4:51 Friday 19th May, 2006
|
|
|
|
|
I can't run that since I have neither the other portion of the form nor zshchita.exe, but just judging from the exception, it looks like you have to remove the line that calls Application.SetCompatibleTextRenderingDefault from zshchita.exe. It's probably in Main().
|
|
|
|
|
My be out of memory?
Any application i was run in TotalComander and Ok result.
But from my application is error.
If this veri hard then stop this idea?
I don't know how to do this.
But i was veri wont to do this!
God bless you. He leves you veri mach.
|
|
|
|
|
I'm pretty sure you can fix it by deleting the Application.SetCompatibleTextRenderingDefault() from the other exe.
|
|
|
|
|
i deleting this but problem don't go out.
Next message was this :
System.InvalidOperationException: Starting a second message loop on a single thread is not a valid operation. Use Form.ShowDialog instead.
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Bblank.Program.Main()
|
|
|
|
|
Try what the error says...
On the line where it says Application.Run(), change it to form.ShowDialog().
|
|
|
|
|
hi all,
let's assume i have form named mehmet and a mainmenustrip on that form like this:
'Properties'
>property1
>property2
>property3
>...
mehmet.MainMenuStrip.Items[0].ToString() gives me the name : <properties>
how can i get any name under Properties ? what should i write instead of mehmet.MainMenuStrip.Items[0].ToString() to get property3 as a result ¿
|
|
|
|
|
mainMenuStrip.Items[0]?
what do you mean?
do you want it's name? what's written in it?
if you want what's written it's not ToString... it's Text...
|
|
|
|
|
Mehmet Fatih Akbulut wrote: what should i write instead of mehmet.MainMenuStrip.Items[0].ToString() to get property3 as a result
mehmet.MainMenuStrip.Items[2].ToString() ?
Your question isn't very clear. What is you are trying to do?
|
|
|
|
|
Hello guys,
Can u suggest me a command in C# similar to GetObject in VB6.0
|
|
|
|
|
What does GetObject in VB6.0 do?
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
GetObject in VB:
if you are running a third party app from ur code lets assume 'mspaint' and due to some reason ur system crashes and is not able to close the instance of 'mspaint' which will now run in background and consume memory.
so GetObject in VB will get this running instance of 'mspaint' and reuse it instead of starting a new instance.
Sorry, i was not clear earlier as this is for the 1st time i am posting a query .... will take care of this in future
Can u pls suggest a similar function in C#
Thanks in Advance
Samoil
|
|
|
|
|
Hi!
You might want to take a look at Marshal.GetActiveObject()[^]
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Hello all,
is any body know how to register windows service using registry Editory.
i need the registry path of that
any suggestions will be appriciated
regards
GV Ramana
|
|
|
|
|
I think the path you're looking for is:
HKLM\SYSTEM\CurrentControlSet\Services
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Good day everyone,
I've been doing a handwriting program. User can use mouse pointer to draw lines and eraser lines
I use 2 methods AddPoint and RemovePoint to add points when user draw lines and remove points when user erase lines by using ArrayList pointArray.
But they're not working
Please help me if you are interested in this program.
Thanks so much
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
if (!isMouseDown)
{
using (sr = new StreamReader("DataPoints.txt"))
{
string str = sr.ReadLine();
if (str == null)
return;
string [] strs = str.Split(' ');
if (strs.Length != 2)
return;
Point pt1 = new Point(int.Parse(strs[0]),int.Parse(strs[1]));
Graphics g = e.Graphics;
while ((str = sr.ReadLine()) != null)
{
strs = str.Split(' ');
if (strs.Length != 2)
break;
Point pt2 = new Point(int.Parse(strs[0]),int.Parse(strs[1]));
g.DrawEllipse(Pens.Blue, pt2.X-2, pt2.Y-2, 4, 4);
g.DrawLine(Pens.Black, pt1, pt2);
pt1 = pt2;
}
}
}
}
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (line)
{
isMouseDown = true;
pt1 = new Point(e.X, e.Y);
point = pt1;
sw = new StreamWriter("DataPoints.txt");
}
if (eraser)
{
pt.X = e.X;
pt.Y = e.Y;
g.FillRectangle(bgBrush, pt.X-10, pt.Y-10, 20, 20);
g.DrawRectangle(Pens.Red, pt.X-10, pt.Y-10, 20, 20);
}
}
private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (line)
{
if (isMouseDown)
{
pointArray.Add("nvcls");
pointArray.Add("Eric");
pt2 = new Point(e.X, e.Y);
Graphics g = this.CreateGraphics();
g.DrawLine(pen, point, pt2);
tempG.DrawLine(pen, point, pt2);
point = pt2;
ptCount = point;
AddPoint(ptCount);
}
}
if (eraser)
{
if (isMouseDown)
{
line = false;
g.FillRectangle(bgBrush,e.X-10,e.Y-10,20,20);
g.DrawRectangle(Pens.Red,e.X-10,e.Y-10,20,20);
g.DrawRectangle(new Pen(this.BackColor),pt.X-10, pt.Y-10, 20, 20);
pt.X = e.X;
pt.Y = e.Y;
RemovePoint(ptCount);
}
}
}
private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (line)
{
isMouseDown = false;
this.BackgroundImage = (Bitmap) tempImage.Clone();
sw.Close();
this.Refresh();
}
}
private void Form1_Resize(object sender,System.EventArgs e)
{
this.BackgroundImage = (Bitmap) tempImage.Clone();
}
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
if ( e.Button == tbPolygon)
line = true;
else if (e.Button == tbEraser)
{
eraser = true;
}
else if (e.Button == tbSave)
Save();
}
public void AddPoint(Point ptCount)
{
pointArray.Add(ptCount);
}
private static void RemovePoint(Point ptCount)
{
for (int i = 0; i <= pointArray.Count; i ++)
{
bool isMatch = Object.Equals(pointArray[i], ptCount);
if (isMatch)
pointArray.Remove(pointArray[i]);
}
}
private void Save()
{
foreach (string s in pointArray)
{
sw.WriteLine(s);
}
sw.Close();
}
eric
|
|
|
|
|
Standard question #1:
What do you mean by "not working"?
---
b { font-weight: normal; }
|
|
|
|
|
Ah, I meant that the method AddPoint and RemovePoint does not work
Is there any other way to add and remove points?
Eric
|
|
|
|
|
Once again, what does not work exactly?
Do you get an error message while compiling, is an exception thrown at runtime or is the data itself not what you expect?
Try stepping through your program with a debugger, that way you'll learn what's going on.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
hi
i have a datagrid that add to it many datagridtextboxcolumn and datagridboolcolumn. my problem is when i read value of they , i can get datagridtextboxcolumn (datagridtextboxcolumn1.texbox.textbox) but don't get value from datagridboolcolumn. how to do that ??
|
|
|
|
|
|
hey...buddies..
once again cought in a problem...actually i want to synchronise folder structures in diffrernt drives using .net framework.so can any one suggest some solutions?is there any thing like web services or so which can help me?..
With Regard
Vikas
|
|
|
|