|
hi i am currently using c#.net to do remoting
i am basically trying to make a project whereby when the client changes the values of the remotable object a function in the main class would execute.
my remotable class is in a class library
i am currently trying to make one of the remotable class object call one of the main class's function
so far all my attempts fail:
i tryed using delegate <==cant as the classes not same file the remotable class dont regconize some of the classes
event handler <== cant as some error keep coming up asking me to serialize the class and when i serialise the class another error pop's up saying that the security is not there to deserialise.
PLEASE HELP ME I AM DESPO
codes i have so far:<br />
static void Main(string[] args)<br />
{<br />
HttpChannel channel = new HttpChannel(8080);<br />
ChannelServices.RegisterChannel(channel, false);<br />
<br />
RemotingConfiguration.RegisterWellKnownServiceType(<br />
typeof(MyRemoteType),<br />
"MyRemoteObject",<br />
WellKnownObjectMode.Singleton);<br />
<br />
MyRemoteType MyRemoteClass = (MyRemoteType)Activator.GetObject(<br />
typeof(MyRemoteType),<br />
"http://localhost:8080/MyRemoteObject");<br />
MyRemoteClass.setsvalue("hihi");<br />
Console.WriteLine(MyRemoteClass.returnstring());<br />
<br />
<br />
<br />
Console.WriteLine("Press enter to stop this process.");<br />
Console.ReadLine();
|
|
|
|
|
my project have some function,but after one function,i must close the program and debug it again then can run the other function.my teacher ask me to add a button, then user finished one function,click this button,the program like refresh then can use the other one.
my question is how to restart the program?hope u can understand what i mean.
thank you.
|
|
|
|
|
Hello,
I would assume that you have to build a second update project wich is started (Process.Start) by your main programm (button click).
After you started the update programm you can Exit the main programm.
Your update program does whatever it should do and restarts the main program again.
Be aware that you have to set the "WorkingDirectory" of your Updateprogramm process explicite, because default would be the mainprogram directory, and then you have problems if you have to delet, move, ... files from the main program.
All the best,
Martin
|
|
|
|
|
Martin ,thanks a lot for u r reply...but i still a little confused about this function...sorry
|
|
|
|
|
So tell us what confusses you!
|
|
|
|
|
System.Windows.Forms.Application.Restart();
|
|
|
|
|
Hey guys thanks for helping, I have the following:
* a main form, mainForm (the main application)
* i have a class, myClass
* i have an auxiliary form, auxForm which displays info about a certain process (method in myClass), say downloadData().
When I make a call to downloadData() the first time, auxForm is created and showed as follows:
<br />
class myClass{<br />
AuxForm myAuxForm;<br />
<br />
downloadData()<br />
{<br />
myAuxForm = new AuxForm (this);
myAuxForm .Show();<br />
doDataLoad();<br />
}<br />
<br />
.<br />
.<br />
.<br />
}<br />
This works fine.
However, once the form has been closed, and I make another call to the above method,
I get an error:
<br />
System.ObjectDisposedException was unhandled<br />
Message="Cannot access a disposed object.\r\nObject name: 'TextBox'."<br />
Source="System.Windows.Forms"<br />
ObjectName="TextBox"<br />
Given that its a textbox on the (closed) form causing the problem, it seems that the object myAuxForm, even though closed/disposed, is not reset to null.
(I have tried doing a if(myAuxForm == null) test before instantiating it again, but with no success).
If anyone has advice on how to get around this problem, it would be much appreciated!
For reference, here is the myAuxForm's code (actually called PriceUpdateForm):
<br />
partial class PriceUpdateForm : Form<br />
{<br />
delegate void OutputDisplayCallback(string s, TextBox txtbxOutputTmp);<br />
StockListManager m_slm;<br />
<br />
public PriceUpdateForm(StockListManager slm)<br />
{<br />
InitializeComponent();<br />
m_slm = slm;<br />
m_slm.m_DisplayOutputEvt += new StockListManager.m_DisplayOutEH(DisplayOutputFromThread);
}<br />
<br />
void DisplayOutputFromThread(string s)<br />
{<br />
DisplayOutput(s, txtbxOutput);<br />
}<br />
<br />
<br />
private void DisplayOutput(string s, TextBox txtbxOutputTmp)<br />
{<br />
<br />
if (txtbxOutputTmp.InvokeRequired)
{<br />
OutputDisplayCallback d = new OutputDisplayCallback(DisplayOutput);<br />
this.Invoke(d, new object[] { s, txtbxOutputTmp });<br />
}<br />
else<br />
{<br />
txtbxOutputTmp.AppendText(s + "\n");<br />
if ((s == "Price data update complete.") && (chbxCloseWhenDone.Checked))<br />
this.Hide();<br />
} <br />
}<br />
<br />
<br />
}<br />
In effect, it comes down to "How to make a call to the same form twice?" I think
Many thanks,
Gerry
C# newbie
|
|
|
|
|
Hi,
Actually Problem is occuring due to your custom event.The work around of this problem is
void DisplayOutputFromThread(string s)<br />
{<br />
if(!this.IsDisposed)<br />
{<br />
DisplayOutput(s, txtbxOutput);<br />
}<br />
}
|
|
|
|
|
Wow thanks sam!
Not sure why the object is still in existence (as its been closed) tho?
Thanks again,
Gerry
|
|
|
|
|
Hello,
The question is if you don't whant to hold the Form in memory and make and only hide it.
If jes, you should add a static "GetInstance" method in your auxForm, which creates an instance at first call and returns it, after that instance != null you return that instanc without creating it new.
The problem of your not accurate disposed class, should not be resolved with an workaround, as this will cause memory leeks and very soon Out of memory exceptions if you go on like this!
As Form is IDisposable and Dipsoe will be called at Close, you should override the Dispose method and unregister the eventhandler you added (-=.....).
Hope it helps!
All the best,
Martin
|
|
|
|
|
Thanks Martin thats some great advice!
|
|
|
|
|
|
i have a gif file with me,and want to place that in the from .
i tried with picture box but its doen't animating.
do we have any other controls or techniques to achieve this?
My small attempt...
|
|
|
|
|
Hello,
sujithkumarsl wrote: i tried with picture box but its doen't animating.
PictureBox, works for me.
Bitmap bmAnimated= new Bitmap(@"......\AnimatedPicture.gif"));
this.pbAnimated.Image = bmAnimated;
All the best,
Martin
|
|
|
|
|
Thanks a lot
My small attempt...
|
|
|
|
|
I have to develop this program(using C#):
Make a main program with a form in it, and a DLL to go along with it all.
In the DLL, add a text file and make, using the property box, the text file's property an embedded resource. Then, using reflection (i suppose), have the main program read the test file and post it to a form.
Plzz tell me how can i access that text file. and Is reflection necessary for it?
And how to achieve reflection?
Plzz reply soon
|
|
|
|
|
ya reflection is necessary for accessing any embedded resource. Get the reference of assembly and read your file in stream.
e.g.
System.Reflection.Assembly a=Assembly.GetExecutingAssembly();<br />
textStreame = a.GetManifestResourceStream("MyProject.MyTextFile.txt")));
|
|
|
|
|
I think that this article does exactly what you want:
Understanding Embedded Resources in Visual Studio .NET[^]
IrfanHaleem wrote: and Is reflection necessary for it?
Well, the Assembly class is in the Reflection namespace, so technically, yes. But you don't have to dig around in the data to get the resource, just use the GetManifestResourceStream method in the Application class.
Example:
Assembly me = Assembly.GetExecutingAssembly();
using (StreamReader reader = new StreamReader(me.GetManifestResourceStream("MyApplication.MyTextFile.txt"))) {
MessageBox.Show(reader.ReadToEnd());
}
-- modified at 5:02 Thursday 10th May, 2007
---
single minded; short sighted; long gone;
|
|
|
|
|
hi everybody,
i had created an application in c# now i want it to run in screen server mode how could i acheive it. Please give me some clue if possible send me some code.
|
|
|
|
|
trap the mouse move and key press events
|
|
|
|
|
|
What data type should be good to represent a series of data (string, double) in turns of efficient and ease. In my series, it usually have about 5000 - 10000 values.
say,
JAN FEB MAR APR MAY
200 400 403 202 122
I wanna do some calculation based on a series of value, then emit another series, so I'd like to use a class to represent them. The order of the value pairs does matter as well. Thanks
Hiya, Everybody ^^
|
|
|
|
|
List<string>
List<int>
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Sorry to tell I'm still using VS 2003, without generic support.
I think I'll go for ArrayList to achieve the goal.
Thanks anyway.
Hiya, Everybody ^^
|
|
|
|
|
hai this is srinu.. am working on remoting ..am facing some difficulties while running GUI based applications.. my problem is .. i want to get remote GUI into local machine..clearly i have a dailog box in remote machine ...i want to get that dailog box using remoting into local machine ...can u plz help me .. is it possible to get that remote dailog into local machine.. gerally am getting any kind of text messages form server through remoting.. but am unbale to get dailog box ..can u plz help me to solve this problem..
thanks in advance..
Thanks,
Srinu.
|
|
|
|