|
My context is , am catching he exceptions thrown from sql server in c# app and throwing as is. So, are you saying that to first launch "Set Language" statement from c# app before performing any SQL actions and that will throw localized exception messages?
|
|
|
|
|
Yes that's the idea. If I execute the following:
SET LANGUAGE Italian
SELECT * FROM NonExistingTable
The result is:
Msg 208, Level 16, State 1, Line 2
Il nome di oggetto 'NonExistingTable' non è valido.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
thanks Mika, i will try that.
|
|
|
|
|
You're welcome.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
I've only just started looking at Pointers and all that memory address changing and I want to be able to specify what address i want to change like 0023ff7c
Is this possible or have i completely got the wrong idea what pointers can do?
ta
|
|
|
|
|
That depends on what you think you can do with it. Yes, you can have a pointer look at any pipece of memory. No, you can't just poke anything you want, wherever you want. Also, from your applications point of view, it's the only app running on the machine, besides Windows. You can't just poke a byte into an arbitrary address and expect another application to see the change. It doesn't work like that.
|
|
|
|
|
thanks i don't realy get all this pointers buisness
i'll just give up and not do any more
|
|
|
|
|
Dave Kreskowiak wrote: poke
Ah, I remember the poke keyword on the old Commodore Basic, on the Apple ]['s as well. Used to always kind of snicker about it ( SB material creeping in )...
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Please help me again.
This is the weak dictionary i have created. It is compiling correctly. But when i test it with GC.Collect(), i can still refer to the weak reference values even after calling GC.Collect() method. How is it possible? What is wrong in my code.
namespace TryWeakDictionary{
public class WeakReference<T> : WeakReference {
public WeakReference(T val)
: base(val, false) {
}
}
public class WeakDictionary<TKey, TValue> : IDictionary<TKey,TValue> {
private Dictionary<TKey, WeakReference<TValue>> weakDictionary = new
Dictionary<TKey, WeakReference<TValue>>();
public void Add(TKey key, TValue value) {
WeakReference<TValue> weakRef = new WeakReference<TValue>(value);
this.weakDictionary.Add(key, weakRef);
}
public void Clear() {
this.weakDictionary.Clear();
}
public bool ContainsKey(TKey key) {
return this.weakDictionary.ContainsKey(key);
}
public void Remove(TKey key) {
this.weakDictionary.Remove(key);
}
public bool TryGetValue(TKey key, out TValue value) {
WeakReference<TValue> weakReference;
if (this.weakDictionary.TryGetValue(key, out weakReference) &&
weakReference.IsAlive) {
value = (TValue)weakReference.Target;
return true;
} else {
weakDictionary.Remove(key);
value = default(TValue);
return false;
}
}
}
}
|
|
|
|
|
This is the idea of weak references. Citing MSDN:
"A weak reference allows the garbage collector to collect an object while still allowing an application to access the object. If you need the object, you can still obtain a strong reference to it and prevent it from being collected."
Your code is OK.
EDIT: I have tested your code and it works as expected. How did you make youre tests?
Like this?
static void Main(string[] args)
{
TryWeakDictionary.WeakDictionary<int,> wd =
new TryWeakDictionary.WeakDictionary<int,>();
for (int i = 0; i < 100; i++) {
wd.Add(i, new C { Data = "abc" });
}
GC.Collect();
C v;
if (wd.TryGetValue(0, out v))
Console.WriteLine(v.Data);
Console.WriteLine("End");
Console.ReadLine();
}
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
modified on Tuesday, November 18, 2008 1:25 PM
|
|
|
|
|
There is nothing wrong in your code. Calling the GC.Collect method doesn't guarantee that all objects that can possibly be collected are collected. The garbage collector still decides what to collect and if there is any reason to do any collection at all.
You should shadow the Target property in the class, so that you don't have to cast it when you use it:
public class WeakReference<t> : WeakReference {
public WeakReference(T val) : base(val, false) {}
public new T Target { get { return (T)(base.Target); } }
}</t>
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Once again, thank you very much. Its all due to my misunderstanding that when i use GC.Collect, GC forcibly collects all objects....
|
|
|
|
|
I want to learn my computer name or others computer name. How can I do it? Could please you tell me how I can do it?
|
|
|
|
|
You can use Environment class.
|
|
|
|
|
I found it. the code is System.Environment.MachineName
|
|
|
|
|
I am transfering a very large file through the web service. So, does web service needs to know about the file size? If so, what is the default limit size.
|
|
|
|
|
Web Services are not supposed to be used for large files. Best to use the web service to give a URL and then d/l from http.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
|
Thanks for answering though.
But what should be the default executionTimeoutInSeconds if i were to set 100MB file size limit. Microsoft web site had 400MB and 300 second set. Do i just take a half of 300 seconds or is there any kind of formula.
<pre>Microsoft website
<httpruntime maxmessagelength="409600" executiontimeoutinseconds="300" />
my web.config
<httpruntime maxrequestlength="100000" /></pre>
|
|
|
|
|
It's quite impossible to say since it fully depends on the network.
You can calculate the theoretical throughput for your network based on bandwiths on participating network segments including your internet connection which, in most cases, is the bottleneck and then use an appropriate portion of it or you can do this experimentally.
Also consider which one is more important to you:
- the download most likely succeeds if it's less than for example 400MB => set a long timeout
- server side doesn't get overloaded by too large messages => limit message length.
Addition:
Forgot to say that you should define both elements in web.config, since you obviously need larger valuer thatn the defaults:
- executionTimeoutInSeconds default is 90 seconds
- maxMessageLength default is 4 MB
The need to optimize rises from a bad design.
My articles[ ^]
modified on Tuesday, November 18, 2008 12:48 PM
|
|
|
|
|
Thanks for such a detailed and articulated answer.
|
|
|
|
|
hi,
do we have any class or library that support the binary trees data structures. what about three ways of traversing. I searched google but I am not convinced based on search result. can someone help me please?
|
|
|
|
|
|
You can find the three basic ways of searching a binary tree in most introductory books on data structures. They are: preorder, inorder, and postorder. Your instructor probably covered these in a lecture.
|
|
|
|
|
he did covbered in lectures in c language but I do assignment in Csharp sp to make the assignment I need to have already a class that stores the data in a binary tree fashion. do we have any built in or already written class by others. yes, Once I have that I can write a recirsive routine to do the type of traverses u mentioned above.
|
|
|
|