The current time is

Tuesday, August 11, 2009

Type.GetType returning null

Writing code that deals with dynamic objects makes you eventually want to work with the types of the object themselves... So you start using "Type.GetType" and by supplying the type as a string... you get the .NET/custom TYPE itself...

And then comes one day that you're surprised that it's not working like you expected it because simply it's returning null instead of returning the correct type!!!

This is because you did not identify the type correctly/fully...

If the assembly name is specified in the typeName string you supplied, Type.GetType() will search inside this assembly only; otherwise, it tries to find one in the caller assembly and then the system assembly (mscorlib.dll).

So, to make your code work, you'll need to specify the AssemblyQualifiedName. For example:
Type.GetType("System.Drawing.Brush, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")

This whole parameter (inside the GetType method) was retrieved by writing that piece of code:
typeof(System.Drawing.Brush).AssemblyQualifiedName

if you try to get the type by just writing it this way [Type.GetType("System.Drawing.Brush")], it won't work and will return the cutie null... :))

Enjoy the DYNAMICS :)))

Who created evil!!! Nice one :)))


If you wish to translate this post, select the output language from here...




من خلق الشر

هذه الرسالة

تجيب في بلاغة عن واحد من أعمق تساؤلات الحياة

هل الله خلق الشر ؟

تحدى أحد أساتذة الجامعة تلاميذه بهذا السؤال :

هل الله هو خالق كل ماهو موجود ؟

فأجاب أحد الطلبة في شجاعة " نعم "

وكرر الأستاذ السؤال " هل الله هو خالق كل شيء ؟ "

ورد الطالب قائلا " نعم يا سيدي الله خالق جميع الأشياء "

وهنا قال الأستاذ ، " ما دام الله خالق كل شئ ، إذا الله خلق الشر . حيث أن الشر موجود ، وطبقا للقاعدة أن أعمالنا تظهر حقيقتنا ،

" إذا الله شرير "

راح الأستاذ يتيه عجبا بنفسه ، وراح يفتخر أمام الطلبة قائلا

" أنه أثبت مرة أخرى خرافة الإيمان بالله "

وهنا رفع طالب آخر يده وقال " هل لي أن أسألك سؤالا يا أستاذي "

فرد الأستاذ قائلا " بالطبع يمكنك "

وقف الطالب وسأل الأستاذ قائلا " هل البرد له وجود ؟ "

فأجاب الأستاذ " بالطبع موجود ، ألم تشعر مرة به ؟ "

وضحك باقي الطلبة من سؤال زميلهم .

فأجاب الشاب قائلا ، " في الحقيقة يا سيدي البرد ليس له وجود . فطبقا لقوانين الطبيعة ، مانعتبره نحن برداً ، هو في حقيقته غياب الحرارة "

واستطرد قائلا " كل جسم أو شيء يصبح قابلا للدراسة عندما يكون حاملا للطاقة أو ناقلا لها ، والحرارة هي التى تجعل جسما أو شيئا حاملا أو ناقلاً للطاقة " .الصفر المطلق هو –460 فهرنهيت أو –273 مئوية هو الغياب المطلق للحرارة . البرد ليس له وجود في ذاته ولكننا خلقنا هذا التعبير لنصف ما نشعر به عند غياب الحرارة .

استمر الطالب يقول " أستاذي ، هل الظلام له وجود ؟ "

فرد الأستاذ " بالطبع الظلام موجود "

فقال الطالب " معذرة ولكن للمرة الثانية هذا خطأ يا سيدي ، فالظلام هو الآخر ليس له وجود ، فالحقيقة أن الظلام يعنى غياب الضوء .

نحن نستطيع أن ندرس الضؤ ، ولكننا لانستطيع دراسة الظلام . في الحقيقة يمكننا استخدام منشور نيوتن لنفرق الضوء الأبيض لأطياف متعددة الألوان ، ثم ندرس طول موجة كل لون . ولكنك لا تقدر أن تدرس الظلام . وشعاع بسيط من الضوء يمكنه أن يخترق عالم من الظلام وينيره .

كيف يمكنك أن تعرف مقدار ظلمة حيز معين ؟ ، ولكنك يمكنك قياس كمية ضوء موجودة . أليس ذلك صحيحاً ؟ . الظلمة هي تعبير استخدمه الإنسان ليصف ما يحدث عندما لا يوجد النور "

وفى النهاية سأل الطالب أستاذه :

" سيدي ، هل الشر موجود ؟ " ...

وهنا في عدم يقين قال الأستاذ " بالطبع ، كما سبق وقلت ، نحن نراه كل يوم ، وهو المثال اليومي لعدم إنسانية الإنسان تجاه الإنسان . أنه تعدد هذه الجرائم وهذا المقدار الوافر من العنف في كل مكان من العالم حولنا . هذه الظواهر ليست سوى الشر بعينه . "

وعلى هذا أجاب الطالب قائلا " الشر ليس له وجود يا سيدي ، على الأقل ليس له وجود في ذاته .

" الشر ببساطة هو غياب الله "

" أنه مثل الظلام والبرد ، كلمة اشتقها الإنسان ليصف غياب الله . "

الله لم يخلق الشر

الشر هو النتيجة التى تحدث عندما لا يحفظ الإنسان محبة الله في قلبه ،

أنه مثل البرد تشعر به عندما تغيب الحرارة ، أو الظلمة التى تأتى عندما يغيب النور ."

وهنا جلس الأستاذ مذهولا

وكان الشاب الصغير هو

ألبرت اينشتاين

Thursday, August 06, 2009

Visual Studio 2005 Getting Latest while checking out... Feature or Bug !!!

Grrr...
Is this a FEATURE or an annoying aspect in VS 2005...???!!!

Visual SourceSafe and all the similar products are made for managing the "versioning" of files so that the whole team of developers can keep track of the latest versions of the files while they're working in a team...

In Visual Studio 2005, when a developer checks out a file to work on, the VS does not get latest for this file, but it just gives him/her access to modify it by flipping the right access from read only to read/write access. How about if some other colleague changed the contents of this file... If so, then one would have to merge the files when he/she's done... THAT is not a good version control system... One should always get access to modify a latest version of the file. Ain't I right???

I searched online to fix this issue and found this post (http://sela.co.il/?CategoryID=975&ArticleID=501&Page=1) which "says" it has the solution...

I hope it works for you... Let me know if it doesn't and if you've got other solutions to this problem... I hope you'd tell me about it too :)))