|
hi, , ive made a remoting server that is hosted in a winapp and it works fine.
now when i try to make it work in a consoleapp the remoting server doesnt respond..
(the code for setting up the remoting channel is the exact same code)
any ideas???
RemConsole.chan = new TcpChannel(int.Parse (port));<br />
ChannelServices.RegisterChannel(chan); <br />
System.Type t=typeof(RaindanceRemoteLib.RaindanceRemote); <br />
RemotingConfiguration.RegisterWellKnownServiceType( t,"Raindance", WellKnownObjectMode.SingleCall);<br />
<br />
RaindanceRemote.Server =server;<br />
RaindanceRemote.ServerPort =5427;<br />
RaindanceRemote.UserName =user;<br />
RaindanceRemote.Password =pass;<br />
<br />
RaindanceRemoteLib.RaindanceRemote.CreateConnections ();<br />
<br />
Console.WriteLine ("press [enter] to exit");<br />
Console.ReadLine ();
does the "readline" block the thread or something??? , ive checked out some samples and atleast in vb.net that should be totally ok to do...
//Roger
|
|
|
|
|
Yes, it should definitely work. I would suspect that your RaindanceRemote class has some dependancy that requires the Windows messages to be pumped. The quick check is to replace your Console.ReadLine() with System.Windows.Forms.Application.Run(). You can still pump messages in a console app.
(I don't see RemotingConfiguration.ApplicationName being set, and off hand I don't know what that lack will do to your URL, but I assume that's no different than your WinForms version.)
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Hi , THANKS!
as you said , the Raindance lib apparently required windows messages.
i replaced the readline with a application.run and it works fine.
thanks
//Roger
|
|
|
|
|
Hi! Im creating a game using C#. Now I need help on how to read combo keys. Like if the user presses ctrl-x, It would then exit the game. Please help.
"To teach is to learn twice"
|
|
|
|
|
Simply handle any of the "key" events on your controls or your Form . I recommend the Form , and then set the Form.KeyPreview property to true so that the form gets a change to handle the key sequences before the controls do, giving you a single point of "key" event handling.
Now, modifiers like Shift and Ctrl don't raise events like Control.KeyDown , but you can get them easily through the Control.ModifierKeys static property, or - depending on which event you use - from the KeyEventArgs that is passed to your event handler.
So, change the KeyPreview event on your form to true . Create a new event handler for the KeyDown event (or the KeyUp or KeyPress events), and do something like the following:
private void MyForm_KeyDown(object sender,
KeyEventArgs e)
{
if (e.KeyCode == Keys.X && e.Control)
{
e.Handled = true;
this.Close();
}
} If you wanted to support user-defineable combos, just pass the KeyEventArgs or part of its data through some key map that wouldn't be hard to create (see the Keys enumeration, which might help).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
In my application, I've created a zip where I store several pictures (256 colors gif)
When my application is loaded, I want to open the zip and load the gif in memory, but it doesn't work as I want, and I'd like some help.
Here is what I do( it's very simplified)
Method 1:
FileStream stream
// Read the contains of the zip with this stream,
// it create Foo.gif (this part works)
stream.Close();
Bitmap Picture = new Bitmap ("Foo.gif");
File.Delete("Foo.gif");
I don't want to keep the file on the hard drive, so I delete it once it is loaded. Pb : I got an error message at runtime "Foo.gif used by another process", and I cannot delete it. But the Stream is supposed to be closed. How can I delete this file?
Method 2:
Instead of using a FileStream to read the zip and save it, I use a MemoryStream, and I create the picture from this stream. It works. Almost. Instead of a 256 colors picture, It create a 32bppArgb picture, so it takes a lot of memory.
Any idea of how I can access the picture in my zip, use them as 256 colors gif, and still be able to delete the picture once I'm done loading it?
|
|
|
|
|
Hai ,
Iam new to C# programming.Iam having a problem when i try to develop a .NET component using COM+ Services. Iam calling a function in a dll
from my component.But it is giving a Build errror saying that the dll is missing the strong name file. I don't have the code for the dll to edit and give strong name file.That dll is developed using VC++.I will be thankful if anybody helps me.
Thanks in advance.
P Ranadheer
M.Tech(CSE)
|
|
|
|
|
hi Guys
how to save a picture in the datadabses , i would be greatfull if u ppl tell me how to load picture in a picture box by using file open dialog , i m looking forward for ur reply
thx
Work Hard and Test your Luck
|
|
|
|
|
Birdy wrote:
how to save a picture in the datadabses
Probably, you'd be best storing the filename in the DB, and storing the images themselves in a different folder. Just my 2c.
Birdy wrote:
i would be greatfull if u ppl tell me how to load picture in a picture box by using file open dialog
Here's for starters (not tested, but should work):
void OpenBitmap()
{
OpenFileDialog dlg=new OpenFileDialog();
ImageCodecInfo[] decoders=System.Drawing.Imaging.ImageCodecInfo.GetImageDecoders();
string allfiltersname="All Supported Bitmap Files (";
string allfilters="";
ArrayList filters=new ArrayList();
for(int i=0;i<decoders.GetUpperBound(0);i++)
{
allfilters+=(i==0?"":";")+decoders[i].FilenameExtension;
filters.Add(decoders[i].CodecName+
" (" + decoders[i].FilenameExtension + ")|" +
decoders[i].FilenameExtension);
}
dlg.Filter=allfiltersname+allfilters+"|"+allfilters+"|"+
String.Join("|",((string[])(filters.ToArray(typeof(string)))));
dlg.Title="Open a Bitmap";
dlg.ShowDialog((IWin32Window)this);
if(dlg.FileName!="")
{
Bitmap b=null;
try{b = new Bitmap(dlg.FileName);}
catch(Exception e)
{
MessageBox.Show(
"The bitmap could not be loaded, because there was an error:\r\n\r\n" +
e.ToString(),
"Error Loading Bitmap!",
MessageBoxButtons.OK,MessageBoxIcon.Error);
}
if(b!=null)
{
}
}
}
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
how can I copy a file to a server?
is it using file.copy???
Nisrine
|
|
|
|
|
Yes.
Using System.IO;
...
File.Copy(SOURCE,TARGET);
or
File.Copy(SOURCE,TARGET,OVERWRITE); where overwrite is true/false
|
|
|
|
|
Is there a way to trap a mouse click on your taskbar window button.
My application does not have the title bar. So am facing two problems.
1. I cannot restore my application by clicking on the taskbar window button, if it is minimized.
2. On Windows 2000 if I choose Minimize All, my app is not minimized along with the other apps.
Help wanted badly!!!
Thanks,
Blade
|
|
|
|
|
I have a ContextMenu with about a dozen MenuItems in it. I've assigned the ContextMenu property of several NumericUpDown controls. When the user right-clicks one of the NumericUpDown controls and then selects a MenuItem from the ContextMenu. This triggers the MenuItem's Click event.
Within the MenuItem's event handler, I need to determine which NumericUpDown control called the MenuItem so I can set the Value property of the NumericUpDown to the appropriate value.
The problem is, I cannot seem to make this happen. The SourceControl of the ContextMenu has a type of "UpDownBase+UpDownEdit". I've found UpDownBase in the docs, but I get casting errors whenever I try to get to the value of the NumericUpDown. Such as...
private void miProg010_Click(object sender, System.EventArgs e)<br />
{<br />
MenuItem mi = (MenuItem) sender;<br />
ContextMenu cm = mi.GetContextMenu();<br />
Control c = (Control) cm.SourceControl;<br />
UpDownBase udb = (UpDownBase) c;<br />
}
Any ideas?
-- James --
|
|
|
|
|
So I kept working on it and discovered the following: The NumericUpDown is a contol composed of other controls. If the user pulls up the context menu by right-clicking the TextBox area of the NumericUpDown, the the ContextMenu's SourceControl can be cast to a TextBox, or you can get the parent of the TextBox which will be the NumericUpDown I was originally seeking. If the user right-clicks the spinner portion, the ContextMenu's SourceContol is the NumericUpDown directly.
So the code that does what I was asking is here:
private void miProg010_Click(object sender, System.EventArgs e)<br />
{<br />
MenuItem mi = (MenuItem) sender;<br />
ContextMenu cm = mi.GetContextMenu();<br />
NumericUpDown nud = null;<br />
<br />
if (cm.SourceControl.GetType() != typeof(System.Windows.Forms.NumericUpDown))<br />
nud = (NumericUpDown) cm.SourceControl.Parent;<br />
else<br />
nud = (NumericUpDown) cm.SourceControl;<br />
<br />
nud.Value = 10;<br />
}
Hopefully this saves someone out there some grief.
-- James --
|
|
|
|
|
Is it possable to grab the Printer settings dialog and postion it where ever I want? I notice that when calling the printer settings dialog, it always goes to the centre of the screen, where I want it to go to the centre of my program
|
|
|
|
|
Since you can't derive PrintDialog , you're going to have to rely on owner messages, which hopefully should work (does in Win32, which the CommonDialog /PrintDialog classes use, but this is untested).
Override the WndProc method of your form (or add a message filter to the Application object, but this can be more difficult to implement). Assuming that the PrintDialog passes messages up the chain, you can access the dialog from the Message.HWnd property. You could run a little test to see if you're getting messages (like mouse messages, just insert a Debug.WriteLine in a test handler to see). If you are, you can handle the WM_INITDIALOG (0x0110) message and P/Invoke a call to SetWindowsPos , passing the HWND of the dialog along wit new site and position information.
See the PSDK docs for more details on SetWindowPos and messaging.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I can get my toolbar to work when clciking a button, but I want to be able to tell - is what button I right clicked on.
Has anyone any idea how to do this?
|
|
|
|
|
Other than overriding the Toolbar class and using Win32 messages to do some of this, or using a pre-canned and much-better toolbar out there (like from Magic controls), there is a completely managed way of doing this.
Hook-up an event handler for either the Click event, or the MouseUp or MouseDown events. Using the Click event does warrant some extra code, but gives you some things for free (like detecting if the user escaped and message before you handle the "up" event). You can get the screen coordinates using the Click event, then use Control.MousePosition to get the screen coordinates, then use Control.PointToClient to get the form coordinates. If you use one of the Mouse* events, you are given the form coordinates.
Then, pass the Point to a function like so:
private ToolbarButton GetButtonFromPoint(Point p)
{
foreach (ToolbarButton btn in myToolbar.Buttons)
{
Rectangle r = myToolbar.RectangleToClient(btn.Rectangle);
if (r.Contains(myToolbar.PointToClient(p)))
return btn;
}
return null;
} You might have to fiddle with the coordinate conversion a little to make sure it works. This code is untested but should give you the basic idea.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Does anyone know how I can draw a dashed or dotted line. I dont seem to be able to get amywhere using System.Drawing.Graphics short of drawing lots of little line. This can be right.
tia
gadget
www.FUXUP.com[^]
|
|
|
|
|
You set it in the Pen that you use to draw (the first parameter in all overloaded Graphics.DrawLine methods). There are many properties (mostly, DashStyle ) that you can set to do dashed lines, and dictate the frequency, length, etc. of those lines.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
If you still have any questions about what all the options are you can check the following article out on the MSDN.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdrawingpenclasstopic.asp
|
|
|
|
|
Thanks, I new there was a way - I just couldnt find it.
|
|
|
|
|
am trying to load JPEG2000 (J2k) image and make use of the scalability features provided by J2k
by showing the image while loading. The tutorials clearly show that there are two possible “modes”:
- Progressive by resolution (You load the picture and it becomes sharper while loading, something
like interlaced GIF)
- Progressive by accuracy (ROI – region of interest)
I am interested in the first: “Progressive by resolution”. So I want to show the image while loading
for example if you download a 2 MB image through Modem connection.
I am looking for a exemplary implementation - does not matter in which language or platform it is running.
I would be grateful for any help.
Regards,
gicio
|
|
|
|
|
Hello, Everyone!
This is my very first post here, and I'm hoping someone can help me out.
I'm not even a novice C# programmer (DBA by trade) but I have a small app I'm working on and need to import a CSV text file into an MS Access Database table using C#.
If anyone can help me out with some sample code I would be very grateful. (I'll even help ya out with SQL code if you need! =)
~Best Regards!
Ray Sotkiewicz
T-Mobile USA
raymond.sotkiewicz@t-mobile.com
|
|
|
|
|
The first thing you want to do is import that CSV file into a Dataset... Best shown here: http://www.codeproject.com/cs/database/asc2xxx.asp[^]
Then you can use that data set to create a table in the access database. Do you need help on that end also?
// Steve McLenithan
Family Guy: Season 2 - Episode 8
|
|
|
|