|
Hi,
First of all, excuse my English.
My app (Compact Framework) loads 2 copies if the same dll (exactly the same DLL renamed) using reflection.
The DLL should load the corresponding config file according to the DLL name (if the DLL is ModuleA.dll the config is ModuleA.txt, and so on).
My problem is this:
When I load the first DLL, everything goes OK, but when I load the second one when I do Assembly.LoadFrom( FullPath ) it loads the first DLL insteag of the 2nd one, despite the fact that FullPath contains the first DLL's path.
In addition there are the variables which shoul be global to each DLL. As everything is loaded from the first DLL, the globals are the first DLL's ones.
After looking for info I realised that what I need to do is to load each DLL in a different AppDomain, so they are isolated from each other.
To summarize:
One compilation: MyModule.dll
2 copies of the same DLL: MyModuleA.dll & MyModuleB.dll
One config file for each DLL: MyModuleA.txt & MyModuleB.txt
One appdomain for each DLL is needed.
Anyone knows how to do this in Compact Framework?
|
|
|
|
|
hi
use LoadFile instead of LoadFrom.
this will help you more
www.codeproject.com/KB/dotnet/AssemblyLoadFile.aspx
cheers
|
|
|
|
|
Thanks for your answer, but i'm afraid it doesn't work in compact framework (mobile), at least in NETCF 2.0.
Thankyou anyway.
|
|
|
|
|
Here's a snippet from one of my classes:
name = System.IO.Path.GetFileNameWithoutExtension ( Filename ) ;
assm = System.AppDomain.CreateDomain ( name ).
Load ( System.IO.File.ReadAllBytes ( Filename ) ) ;
|
|
|
|
|
I'm afraid this doesn't work on Compact Framework 2.0.
Thankyou anyway.
'System.AppDomain' no contiene una definición para 'Load'
'System.IO.File' no contiene una definición para 'ReadAllBytes'
In English:
'System.AppDomain' doesn't contain a definition for 'Load'
'System.IO.File' doesn't contain a definition for 'ReadAllBytes'
|
|
|
|
|
Hi
I want to pass values from one form to another form in windows application. Can anyone help me plz with sample code...
Thanks in advance...
Elizabeth......
|
|
|
|
|
Levae alone Google, did you try to even serach in CP.
I found these [^]answers already present.
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.
|
|
|
|
|
Well I think the best option would be to create properties[^] in the form you want to pass them to and then set those properties with the values...
private string myProperty = "Default Value";
public string MyProperty{
get{return myProperty;}
set{myProperty = value;}
}
you could also pass through a method[^] in the second form...
public void SetValues(string val1, string val2, string val3)
{
MyVal1 = val1;
}
or you could have a list of static members[^] that all forms can access, but this may not be the best solution for what you want...
public static string Val1 = "My Val 1";
...all forms will be able to access this be reference the class/form is belongs to...
MyVal1 = Form1.Val1;
...hope that helps
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Thank u its working.......
|
|
|
|
|
To pass to a form that is a child (i.e. Form1 instanciates Form2 so Form2 is a child of Form1) use a property or method.
To pass from a child to a parent, use an event.
To pass between two children, use an event to notify the parent and the parent in turn uses a property/method to pass to the child.
The first two are in this example.
using System;
using System.Windows.Forms;
namespace ValuePassing
{
public class FormParent : Form
{
public FormParent()
{
Shown += new EventHandler(FormParent_Shown);
}
void FormParent_Shown(object sender, EventArgs e)
{
FormChild formChild = new FormChild();
formChild.ValueChanged += new EventHandler<ValueChangedEventArgs>(formChild_ValueChanged);
formChild.VisibleToParentMethod(100);
formChild.VisibleToParentProperty = 200;
}
void formChild_ValueChanged(object sender, ValueChangedEventArgs e)
{
Text = (string.Format("Value = {0}", e.Value));
}
}
public class FormChild : Form
{
public event EventHandler<ValueChangedEventArgs> ValueChanged;
private int visibleToParentValue;
public int VisibleToParentProperty
{
get { return visibleToParentValue; }
set
{
MessageBox.Show("Property");
SetVisibleToParentValue(value);
}
}
public void VisibleToParentMethod(int value)
{
MessageBox.Show("Method");
SetVisibleToParentValue(value);
}
private void SetVisibleToParentValue(int value)
{
if (visibleToParentValue != value)
{
visibleToParentValue = value;
OnVisibleToParentValueChanged(new ValueChangedEventArgs(value));
}
}
protected virtual void OnVisibleToParentValueChanged(ValueChangedEventArgs e)
{
EventHandler<ValueChangedEventArgs> eh = ValueChanged;
if (eh != null)
eh(this, e);
}
}
public class ValueChangedEventArgs : EventArgs
{
public ValueChangedEventArgs(int value)
{
Value = value;
}
public int Value
{
get;
private set;
}
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi Experts,
I would like to add a usercontrol to Window.ie to Operating systems Window.
when ever i open a MyComputer or MyDocuments, Mine usercontrol should be displayed on it
Thanks
|
|
|
|
|
|
|
Okay, I think I understand now. Are you talking about the M-Files Left Pane on the left side of that window in your image, where it displays various options to perform on selected files? If so, I'm sorry but I can't help you with that.
Good luck,
jase
Edit: I just did a half-as*ed search on Google for "Extending Windows Explorer with Custom Panes C#" and found a whole heap of results.
|
|
|
|
|
The main question I have here is how to improve CPU usage... Memory Usage is not an issue
The Client program connects to the server and sends screen shots (at a rate of 250ms) to the server. This all works well, but I need to use less CPU... The server side program is of no concern either
For brevity purposes, I will simply list what's used. First of all, a TcpClient and a NetworkStream are used. BinaryFormatter serialization is also used to de/serialize objects into byte arrays. The conversion of an object to a string is not quite a choice, since I intend to transfer more objects later on (without having to change much code). A timer with interval of 250ms triggers DoWork method of a BackgroundWorker to take and send a screen shot.
The method used to take the screen shot is:
private Image TakeShot()
{
Bitmap bmpScreenShot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
Graphics grcShotGraphic = Graphics.FromImage(bmpScreenShot);
grcShotGraphic.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
grcShotGraphic.Dispose();
return (Image)bmpScreenShot;
}
I just need to know what's causing such CPU usage and how to improve it. E.g. using Threads instead of BackgroundWorker or a more efficient method to take the screen shot. As I have said, Memory Usage and Network load is of no concern. Furthermore, I know that increasing the interval would result in better performance, but I am looking for something other than that. Current CPU usage ranges between 20-40% on an Intel Core 2 Duo E7300
|
|
|
|
|
|
Whilst I would like to thank you for taking the time to read and attempt to resolve the problem, that actually made the situation worse. Since on average, CPU usage increased by another 2%.
|
|
|
|
|
Hi,
there is two parts to my answer:
1.
so those five lines of code are executed over and over in some loop. Now which lines do you not really need all the time? I can name three, possibly four, depending on what happens to the resulting bitmap. I guess taking advantage of that would make it less expensive by a factor of I'd say 3.
2.
remote PC access utilities normally do NOT transmit the entire screen over and over; instead the current screen is compared with the previous one, and only the differences are transmitted. That would be a medium-complexity challenge as the .NET image classes don't really support that AFAIK.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks about that... I'll check Part 1 you mentioned. However, with regards to Part 2, that would only improve the Server or the network bandwidth, but not the processing, since a lot of time is spent comparing...
However, thanks for taking the time to answer... Please provide me with the possibilities of reducing the lines in the ScreenCapture method. Thanks!
|
|
|
|
|
I have a string. The value of that string contains some english and non english characters.
I have two requirements:
1) Determine whether the string contains non english characters.
2) Remove all the non english characters from the string and get the resultant string which contains only english characters.
How can i do so ?
Imtiaz
|
|
|
|
|
Convert each character into a byte (you can use the convert class), and then check the byte's against the ASCII table.
capital A to Z = 65->90 numeric
lower case A to Z = 97->122 numeric.
You would have to check for other characters you wanted to keep though. (i.e comma's fullstops etc etc).
<br />
string word = "fdffd";<br />
foreach (char c in word)<br />
{<br />
byte b = Convert.ToByte(c);<br />
if ((int)b > 65 && (int)b < 90)<br />
{<br />
}<br />
else if ((int)b < 97 || (int)b > 122)<br />
{<br />
}<br />
else<br />
{<br />
word.Replace(c.ToString(), string.Empty);<br />
}<br />
}<br />
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
Click here to view my blog
|
|
|
|
|
MarkBrock wrote: Convert each character into a byte
That seems unnecessary, as does the casting to int.
If you want to do it that way, just use if ( ( c >= 'A' ...
|
|
|
|
|
Your right .
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
|
|
|
|
|
Do you want to have only alphabetic characters? Or do you also want digits and symbols too?
|
|
|
|
|
I want digit numbers too.
Imtiaz
|
|
|
|