|
Microsoft have a good marketing strategy that is true. But don't think microsoft playing marketing strategy in technologies that they are providing to developers. If so their product own survive in this competative industry. This is the first thing you need to know. This is fact (Don't worry i am not working for MS Corp).
See here you didn't mention which laguage that you are using to do deterministic destruction. So please specify that language first.
One more thing , here in CP we have an article which will deals the Diterministic Destruction. It's actually in MC++ by some other. Cool;)
Sreejith Nair
[ My Articles ]
|
|
|
|
|
"Microsoft have a good marketing strategy that is true. But don't think microsoft playing marketing strategy in technologies that they are providing to developers. If so their product own survive in this competative industry. This is the first thing you need to know. This is fact (Don't worry i am not working for MS Corp)."
______________________________________________
Don't worry - I wouldn't hold it against you. I consider MS to be the best software company there is (which is not to say "ideal" or "fair"). But as a matter of fact I *do* think that they are tweaking programming languages for marketing purposes. I fail to see any other possible reason for removing keyword "delete" from a programming language other than to boast about GC doing all the work for you. It doesn't and writing destructors is absurdly complicated with .NET documentation trying to scare you into not doing it, quoting some huge performance overheads. What (non) quality IDisposable offers... well - I've already stated my opinion.
"See here you didn't mention which laguage that you are using to do deterministic destruction. So please specify that language first. "
______________________________________________
Er... but i *did* post the message in C# forum, now didn't I? C# obviously.
"One more thing , here in CP we have an article which will deals the Diterministic Destruction. It's actually in MC++ by some other. Cool"
______________________________________________
Yeah, read it. Won't help me much. As there apparently is absolutely no way of clearing the memory manualy, well... I guess I'll just have to provide some instance managers for essential objects. Geez, how much time I save thanks to the whole autoGC idea - amazing, isn't it?
Thanks anyway.
|
|
|
|
|
nurglitch wrote:
I fail to see any other possible reason for removing keyword "delete" from a programming language other than to boast about GC doing all the work for you
Java doesn't have a delete operator either. Was that for marketing purposes? Magik doesn't have a delete operator (and that is one of the most academically oriented commercial languages I've ever used), was that for marketing purposes?
nurglitch wrote:
What (non) quality IDisposable offers... well - I've already stated my opinion.
Can you give me an example in another language where if you delete an object all references to it instantly change to null?
Perhaps you should look at using a WeakReference[^].
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Can you give me an example in another language where if you delete an object all references to it instantly change to null?
I second Colin's comments; in particular even C++ doesn't do that.
Here's an example of bad code that someone under the contrary illusion might create:
void StupidFunction( SomeObject * o )
{
delete o;
o = null;
}
SomeObject * obj = new SomeObject();
StupidFunction( obj );
if( obj )
{
obj->Bronk();
delete obj;
}
Anyway, what exactly is the problem you are trying to solve? Perhaps there is a good C# idiom to handle that problem, instead of trying to make C# be C++. Are you trying to make sure an object is not used after it is invalid? Then maybe it should have some internal validity checking that is done whenever it is used. Or are you worried about memory usage? If so, then fooling around with GC() still might not help, since the VM may still keep memory from the OS, even in cases where it could return it (keeping it around for other object creation). This is all performance tuning stuff that may not be within your control (and probably shouldn't be). Anyway, even if you could have this ability to delete an object and have all references to it become null, wouldn't that just cause NullReferenceExceptions all over the place? If you have references to an object that you don't know about, then magically "nullifying" them doesn't seem like a great idea.
If you really need to worry about bits and bytes of memory allocation, you probably shouldn't be writing mangaged code; in such cases, I like to create a COM automation library that I can call from C#. You could also just create a "plain old" dll that you call with DllImport.
Once again, it boils down to what exactly you are trying to do.
Matt Gerrans
|
|
|
|
|
Hi!
I´m working on a project where we are making a hook for an other software. Now we have encountered a problem and I would like some help on finding a work-around.
When we are opening a new form in the hook an exception is thrown and the form is destroyed. The exception is a System.TypeInitializationException that says that "The type initializer for "System.Drawing.SafeNativeMethods" threw an exception. -->System.NullreferenceException: Object reference not set to an instance of an object".
I have traced the exception into the InitializeComponent() method and it is thrown when the first component on the form is initialized. This exception does not appere every time, but once in a while. I can not see any real reason for the problem and we are not doing any different when it works and does not.
I have searched the net and found others that have had the same problem, mut I have not found any good solution. The problem seems to be in GDI+, at least that is what how I have understod it when reading posts on other forums..
The application loading the hook is creating appDomains for all hooks so that it can unload them as it whishes, I think that this might be the root of the problem, or? We would really need to show this form, its for configuring the hook, and the main application really needs to unload the hooks now and then, so the problem is a fact.
Is there any good work-around for this? Is there anything we can do to solve this problem without having to make changes in the main application?
All help appriciated!
Regards Mikael
|
|
|
|
|
Hi,
I have created a domain user through code using ActiveDs. I want to add that user to administrative group using c#.
i have to do the same in workgroup environment also
Please help me to solve this problem
Thanks in advance
Regards
Subin
|
|
|
|
|
I have tried passing variables (strings) by reference to a new, daughter form where the values will be manipulated. This works and the new values are clearly seen on the parent form during debuging. BUT, when the daughter form is closed the modified values are lost and the parent form has only the origional values.... can this be correct? Is this by design (an 'undocumented feature') or have I missed something important here?
Peter Beedell
"Remember that age and treachery will always triumph over youth and ability." Quoted from the BBC Comedy 'The Office'.
|
|
|
|
|
This is all be designed, and well-documented if you read the .NET Framework SDK. While a String is a reference type (and, hence, always passed by reference - at least in C#), it is immutable; any changes you make to the string are actually made on a copy. Why do you think that methods like String.Replace return a string?
If you want to modify a string from a method in a child class, either return a string from your method or default an out or ref parameter like so:
using System;
class Test
{
static void Main()
{
string value = "Hello, world!";
Console.WriteLine(value);
value.Replace("Hello", "Guten tag");
Console.WriteLine(value);
Change(ref value);
Console.WriteLine(value);
}
static void Change(ref string value)
{
value = "Tschuss!";
}
} For value types - numbers, enumerations, and structures - they are always passed by value, so you have declare value type parameters using out or ref if you plan on changing their values.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Stewart, thanks for responding only I think you have missed my point.
Passing my string variables by reference to methods on a daughter form (modal dialog) indeed seems to work. Changes to the referenced object are seen on the parent form as if they are one and the same - which is exactly what I expected and wanted. What I do not understand and what is causing me a problem, is that when the daughter form is closed, the referenced objects resort back to their origional values.
Even if this is as described in the SDK, it seems to me to be rather un-helpfull and illogical.
Peter Beedell
"Remember that age and treachery will always triumph over youth and ability." Quoted from the BBC Comedy 'The Office'.
|
|
|
|
|
What referenced objects? The string you're passing to your modal dialog from your parent form? Some code snippets would be helpful, since what I said about strings in my previous post is true. When you assign a string you change the reference to another string object or literal. Unless that string is passed by ref or out it wouldn't change in the parent form. So, again, some code snippets would be helpful.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Dear all,
im a c and c++ programer now im jumping in the C# world. im creating a screen saver from c# how can i create a full scrren plaes help with short code.
thank you
biran
Biran
|
|
|
|
|
If you search[^] for "screensaver" in the search box just below the logo on every page on this site, you'll finds lots of examples and articles about creating screensavers in C# (and in .NET, in general).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Dear Microsoft,
thank you for the reply, actualy i am writing same like screen saver but not screen saver. My question is this how to create full scrren window? in c#,
i am not using wizard i am writing by empty project and code base.
please help again.
thank you
biran
Biran
|
|
|
|
|
biran wrote:
Dear Microsoft
No, my name is Heath. As my sig implies I do not speak for Microsoft unless I'm explicitly saying I do. I do this of my own free will and on my own time as I have for the past few years here on CodeProject.
If you look at some of those articles, it explains exactly what you have to do to your Form :
using System;
using System.Drawing;
using System.Windows.Forms;
class Test : Form
{
static void Main()
{
Application.Run(new Test());
}
Test()
{
FormBorderStyle = FormBorderStyle.None;
Bounds = Screen.FromControl(this).Bounds;
Button btn = new Button();
Controls.Add(btn);
btn.Location = new Point(8, 8);
btn.Text = "Close";
btn.Click += new EventHandler(Close);
}
private void Close(object sender, EventArgs e)
{
Close();
}
}
You set FormBorderStyle to FormBorderStyle.None and set the size and location (bounds) of the form to that of the entire screen.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi, I need a suggestion on securing a database. I have a table which has new values inserted by importing a csv file. These rows are then marked as used, when a client uses a voucher number associated with that row. I have a hash value for each row which ensures that a user cannot just reset its used status.
However, I realise that a user could very easily just delete that row and reimport it. I know this cannot be stopped, but I just need some suggestions on how I could ensure they are not doing this. DB level security will not work, as each computer which will use this app is standalone, and the owner of the computer will have all rights to the db through the SA login. Can I block the database owner from modifying the table?
|
|
|
|
|
Either parse the input and block on any violations according to your requirements, or realize that if the user has SA privileges there's nothing you can do anyway.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
|
Hi, I am interested in your idea, but not to sure what you mean. Would the trigger be used to prevent an update?
|
|
|
|
|
|
I have multiple printer drivers installed (e.g. EPSON, RICOH, CANNON) on my computer. Is there any way to check/get the PrinterSettings of any of them using Printer Name? i.e. if I want to check EPSON printers PrinterSettings that may not be the default printer, how to do it?
Please guide
|
|
|
|
|
Use the static PrinterSettings.InstalledPrinters collection property to get a collection of the printer names. You can enumerate this collection, or if you know the name of the printer, you can set PrinterSettings.PrinterName , like in the following example:
PrinterSettings printer = null;
foreach (string name in PrinterSettings.InstalledProperties)
{
printer.PrinterName = name;
if (printer.IsValid)
{
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
thanks for the reply.
continuing the same topic;
How to set any one of Printers as Default Printer?
regards
|
|
|
|
|
The easiest way is through WMI. While on NT-based platforms you can make a single function call (you have to P/Invoke SetDefaultPrinter ), the steps for Windows (i.e., Win98 and ME) platforms are more numerous.
WMI exposes a Win32_Printer.SetDefaultPrinter method that abstracts the correct implementation:
using System;
using System.Management;
class Printers
{
static void Main(string[] args)
{
EnumeratePrinters(args.Length > 0 ? args[0] : null);
}
static void EnumeratePrinters(string defaultName)
{
ManagementObject defaultPrinter = null;
ManagementObjectSearcher searcher = new ManagementObjectSearcher(
"select * from Win32_Printer");
foreach (ManagementObject printer in searcher.Get())
{
string name = printer["Name"].ToString();
Console.WriteLine("Printer: " + name);
if (defaultName != null &&
string.Compare(name, defaultName, true) == 0)
defaultPrinter = printer;
}
if (defaultPrinter != null)
{
Console.WriteLine("Setting default printer to \"{0}\"",
defaultPrinter["Name"]);
defaultPrinter.InvokeMethod("SetDefaultPrinter", null);
}
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi~
I am writting a program to get the email using MAPI by P/Invoke.
Except inbox, Can I get the emails item from other folder such as outbox?
Thanks
|
|
|
|
|
hi,
how to preprocess "ctrl + c" in console program,i want to using .net class implement this function.
thanks
|
|
|
|