|
I have read books, it's just that none of them were advanced enough to mention this in detail. I really guessed the answer, but I can never be sure. Could you please recommend a good enough advanced book about these issues?
Thanks for everything.
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
hello there
im not a pro c#, u might say im a beginer.
but i best learn from expiriance so i decided to
program a "complex" application.
ofcourse every software need a configuration form
so i made up a class with all members/vars to stream
to the configuration file.
and now, here is my question:
instead of writing members values to file
one by one, can i make a trick to loop trough all
members?
so if tommorow i add 5 more values (font, loc, color..etc)
the saving method wont have to change.
is it possible?
|
|
|
|
|
Sounds like you are reinventing a wheel. The .NET framework has support for automatic serialization. Its pretty much as simple as adding a [Searializable] attribute to your class definition. Have a look at this[^].
Ryan
|
|
|
|
|
thank you
i knew there is something like that
but didnt find enough info.
thanks again
|
|
|
|
|
Hi ,
I had created a toolbar and need to deploy it over the internet . I created a cab file with an ini file in it . This cab file was referenced from a html page through the OBJECT tag . The cab file was aldo digitally signed with a certificate created with the help of the tools available in .net . But when that page is referenced the installation does not take place .
Please help . Where could i have gone wrong . The OSD file everything has been written with the help of instructions from the MSDN documentation .
And how do i run a dos command from an ini file . I tried usig the run statement but it didnt work . Please tell me how to do it . If run is the command then please send the syntax for the run statement .
Srikar Y
NITK Surathkal
|
|
|
|
|
.NET != ActiveX, or
.NET <> ActiveX
In order to distro a .NET control in a CAB file, it has to expose it's controls as, at most, IUnknown class interfaces (or use IDispatch class interfaces to make it scriptable, given the proper security context).
If you look at the section of the .NET Framework SDK documentation entitled "Deploying Applications", you'll see that you really should use CAB files at all. Instead, you use a slightly modified <OBJECT> tag that reference the assembly and class directly. Then, if the site or URL is allowed the proper security priviliges by the .NET framework, the control will be instantiated directly. Any public properties of the control that have a TypeConverter to read/write strings can be set using the <PARAM> tags inside the <OBJECT> tags, such as a URL to an INI or XML file to build the toolbar.
CAB files can be used, but it is generally not done because the .NET model allows for assembly bindings over the Internet in a seemless fashion. Fusion - the assembly binder - will download assemblies to a temporary assembly cache that is based on the assembly name. The next time the same version is used, it will be pulled from the cache and load / insantiate faster. A CAB file doesn't give you this functionality.
There are a number of other things, too. An embedded user control, as the method I'm describing is most often called, CANNOT use any values from the SystemColors class, as most controls do. This is documented and is because the control requires full trust and, for some reason, this class requires unrestricted access or something like that. Frankly, based on what I know about security and the CLR (which is quite a lot), Microsoft's statement has never made sense.
Also, the control has to be granted enough permissions to run. .NET basically runs in a Java-like sandbox, although .NET is much easier to use and configure. If the CLR isn't told to grant enough permissions to your control to run based on its evidence, it won't execute it.
I wrote an article about all of this some time back on a different site and haven't ported it over yet. Perhaps it would be a good time, since I could probably update some information on it. Take a look at the following URL:
http://www.devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=388[^]
I hope that helps.
-----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-----
|
|
|
|
|
Hi everybody,
My problem is returning my entity objects though the autogenerated web service proxy class.
Explanation:
Projects:
Class library (containing entities)
Web Service (instantiating entities with values from database)
Smart Client (windows forms)
The entity class library is shared between web service and smart client.
What I want to do is sending my entity objects to my smart client, but the proxy class obstructs that by creating a webservice.Vendor class which holds only the public properties as public variables instead of the entity.Vendor class...
The result is that i cant just typecast the proxygenerated Vendor class into my entity.Vendor class. Ive found a "hack" for this by editing the proxy class myself. But that is indesirable as it is overwritten each time I update the web reference due to updates in the webservice...
HELP!
If you need futher details plz do ask
Best regards
Alex
|
|
|
|
|
Have a look at this article[^], it uses CodeDom to generate a wrapper class for the wsdl.exe generated proxy, which exposes properties instead of variables. DataBinding heaven.
I have a C# version if you would prefer that.
Ryan.
|
|
|
|
|
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?
|
|
|
|
|