What is TypeForwardedToAttribute?

Note: The actual class name is TypeForwardedToAttribute. (not TypeForwardedToAttributes )

TypeForwardedToAttribute class is new class in .NET framework 2.0. It helps you to move the existing classes (types) from one assembly to another without breaking to the existing application.

Before this feature is not available in .NET framework, it’s too much work if we wanna move the existing classes to another assembly for any reason because it can’t be done without recompiling the existing applications which are using that assembly. For example, there are one class called Class1 in assembly1. There are one window application called WinApp which is using that assembly “assembly1″. We wanna move that class “Class1″ from assembly1 to another assembly called “assembly2″. In order to do that, we have to remove that class from assembly and add it to assembly2. Then, we have to add this new assembly as a reference to WinApp. Then, we have to recompile this application again. It’s gonna be the problem if we don’t have the source code of WinApp. Even we have the source code, it’s like too work to do.

Now, things has changed. TypeForwardedToAttribute has come for this need. I will show you how this class is useful with the following demonstration (or steps)

  1. Create a new class library called “ClassLibrary1″ in Visual Studio .NET 2005.(There will be one class called Class1 already included in this class library.)
  2. Write one public method (eg: Method1() ) in that class “Class1″.
  3. Write one piece of code to show the messagebox when this method is invoked.
  4. Add Window application in Solution Explorer
  5. Add ClassLibrary1 as a reference to Window application
  6. Add one button on winform.
  7. Invoke the method from Class1 in the click event of this button. (eg: ClassLibrary1.Class1.Method1(); )
  8. Build and Run the application. (Check whether the messagebox is shown or not in button’s click.)
  9. End the running.
  10. Remove the window application. (we already ensure that this window application is working fine with ClassLibrary1.Class1.Method1(); If you wanna ensure more, you can run and test the executable file of window application under bin/debug folder. )
  11. Add new class library project called “ClassLibrary2″ in Solution Explorer.
  12. Move Class1 from ClassLibrary1 to ClassLibrary2. (You should note that the name of namespace must not be changed. )
  13. Add ClassLibrary2 as a reference to ClassLibrary1 project.
  14. Open the assembly.cs in ClassLibrary1 project (this file is under the properties folder of project file.)
  15. Add the following code in assembly.cs of ClassLibrary1
    [assembly: TypeForwardedTo(typeof(ClassLibrary1.Class1))]
  16. Recompile the ClassLibrary1 and ClassLibrary2. ( it’s not necessary to recompile the window application which is using ClassLibrary1. )
  17. Copy the ClassLibrary1.dll and ClassLibrary2.dll from bin/debug/ folders.
  18. Place them into bin/debug folder of window application.
  19. Then, run the exe file (eg: windowapplication.exe) and check whether the messagebox is shown or not. (I’m sure that your window application works just fine and you will see the msgbox. :) )

So, We dont need to touch Window application for adding ClassLibrary2.dll. Window application keep using ClassLibrary1. When window application requests the type to ClassLibrary1 then ClassLibrary1 will forword to ClassLibrary2 by using TypeForwardedToAttribute. So, it’s not necessary to recompile the window application.. It makes the developers’ lift easier. :)

Okay. That’s all from my side. What do you think? If you have any question for this class or my explanation or the steps mentioned in my article, please feel free to let me know.

Thanks.

Poems written by husband to wife

I wrote your name on sand it got washed.

I wrote your name in air, it was blown away. Then

I wrote your name on my heart & I got Heart Attack.

******

God saw me hungry, he created pizza .

He saw me thirsty, he created Pepsi .

He saw me in dark, he created light .

He saw me without problems, he created YOU.

******

Twinkle Twinkle little star

You should know what you are

And once you know what you are

Mental hospital is not so far.

******

The rain makes all things beautiful.

The grass and flowers too.

If rain makes all things beautiful

Why doesn’t it rain on you?

******

Roses are red, Violets are blue

Monkeys like u should be kept in zoo.

Don’t feel so angry you will find me there too

Not in cage but laughing at you.

All screenshots of Google Theme (iGoogle)

I believe that all of you already knew about iGoogle (formally known as “Google Personalized Home Page”) and its gorgeous themes. The interesting thing is that those theme can be changed dynamically based on either local time or weather.

There are six different themes as picture above in iGoogle. ( Actually, there are 7 themes available but “Winter scape” is a hidden theme which can’t be directly accessed. ) All of those themes are divided into 2 categories such as Weathe-based theme and Time-based theme. The weather-based theme is a theme which shows the different design based on local weather condition. For example, we will see raining theme if it’s raining in our location. The time-based theme does the same but based on local time. For example, we will see night-view theme at night.

Weather-base theme

  • BusStop

Time-base theme

  • Spring Scape
  • Beach
  • City Scape
  • Sweet Dreams
  • Tea House
  • Seasonal Scape

The BusStop theme is based on local weather condition while all others are on time.

The reason why I write this post is that I wanna share something that I found on iGoogle last weekend. The story started when I was eagerly to know how many pictures included in each theme. I didn’t know how to find out for those images. The first flash I got is that Google Gadget are created based on XML file. So, I believed that I will get the path of those images when I got the link of XML file. Then, I googled a lit for that and I found the list of xml files as below.

XML file of Google Theme

  1. http://www.google.com/ig/skins/springscape.xml
  2. http://www.google.com/ig/skins/teahouse.xml
  3. http://www.google.com/ig/skins/beach.xml
  4. http://www.google.com/ig/skins/cityscape.xml
  5. http://www.google.com/ig/skins/sweetdreams.xml
  6. http://www.google.com/ig/skins/busstop.xml
  7. http://www.google.com/ig/skins/winterscape.xml

Images of Spring Scape

3.14 AM

6 AM

8 AM

10 AM

Noon

2 PM

4 PM

6 PM

8 PM

10 PM

Midnight

2 AM

4 AM

Images of Tea House theme

3.14 AM

6 AM

8 AM

10 AM

Noon

2 PM

4 PM

6 PM

8 PM

10 PM

Midnight

2 AM

4 AM

Images of Beach theme

3.14 AM

6 AM

10 AM

Noon

2 PM

4 PM

6 PM

8 PM

10 PM

Midnight

2 AM

4 AM


Images of City Scape

3.14 AM

6 AM

8 AM

10 AM

Noon

2 PM

4 PM

6 PM

8 PM

10 PM

Midnight

2 AM

4 AM

Images of Sweet Dreams theme

3.14 AM

6 AM

Images of Winter Scape

3.14 AM

314-am.jpg

6 AM

6am.jpg

8 AM

8am.jpg

10 AM

10am.jpg

Noon

noon.jpg

2 PM

2pm.jpg

4PM

4pm.jpg

6PM

6pm.jpg

8 PM

8pm.jpg

10PM

10pm.jpg

Midnight

might.jpg

2 AM

2am.jpg

4 AM

4am.jpg

Images of Bus stop theme

Cloudy

cloudy.jpg

Mostly Cloudy

mostlycloudy.jpg

Hazy

hazy.jpg

Foggy

foggy.jpg

Snowy

snowy.jpg

Flurries

flurries.jpg

Icy

icy.jpg

Windy

windy.jpg

Rainy

rainy.jpg

Stromy

stromy.jpg

Thunder

thunder.jpg

Yeah. I’m done.. :) Those are the images from Google Theme.

The following code is cool trick that I got from this link. Go to XML file (that I already mentioned above). Find out the path of CSS file. Type the code with the path of CSS file that you wanna changed.

javascript:void(document.getElementById("ext_css").href="/ig/skins/winterscape/winterscape_3.14am.css");

What do you think? do you like it?? :)

Related ~

CSS Designs Competition – Win $ 1000

UPDATED:: This competition is over. The official website ["www.sndbx.org"] for this competition is no longer available.

What is it all about?

This competition is all about customizing the Sandbox theme by using CSS and images without touching PHP code. It’s like WordPress theme competition but its focusing on designing thing so that it’s good for web designers. (You don’t need to know anything about PHP code, WordPress Template API and etc)

Deadline : 12:00 AM UTC, July 29, 2007

Purpose of this competition

  • Promoting Premium CSS upgrade in wordpress.com
  • Promoting Sandbox Theme
  • And ~

    * To be transparent, organized, and fun;
    * To solicit new, excellent designs to benefit the WordPress community;
    * To reinvigorate the creative energy present in the WordPress community; and,
    * To provide a challenging competition appropriate for experienced and novice designers.

Prizes

* Total Competition Prizes: US $1000 or $1950.00

  • 1st prize: US$850
  • 2nd prize: US$550
  • 3rd prize: US$400
  • First three (3) runner-ups will receive US$50 honorarium and a copy of Blogging Tips by Lorelle each

1. First prize. The Contest champion will win US$500.
2. Second prize. The Contest second-place winner will win US$300.
3. Third prize. The Contest third-place winner will win US$200.
4. Runner-ups. The Contest runner-ups will receive honorariums.

Odds of winning a prize will vary depending upon the number of actual Contest participants. In the event any entry is deemed ineligible, the Administrator may award the prizes to alternate entries as it deems suitable. Winners may be required to pay customs, duty charges and/or taxes.

Note: It’s better if you check the latest news about prizes in this site since it keep on changing all the time.

Who launched this competition?

The competition is lunched by Scott of plaintxt.org, who is the cocreator of the Sandbox along with Andy of Automattic.

Rules

  • All designs will be limited to style sheets (CSS) and images (no theme PHP mods)
  • Designs must be released with GNU General Public License or compatible license. (Keep in mind that it’s not CC license. So, no one is gonna give you any credit even they are using your design.)
  • Designs may only be released publicly after submissions close (You are NOT allowed to attach your theme as a zip file in your blog. but you can show how your theme looks like in your blog. )
  • You are allowed to submit multiple entries in different emails (eg: Submission: My Theme1, Submission: My Theme2 and so on.)
  • Everything (icons, images or etc) that are used in your theme should be under GNU. (Don’t forget to check the license before copying the image from websites or search engines.)

- Send to submissions@sndbx.org with the subject “Submission: [Title]“, where [Title] is the name of the design.

The submission attachment must be a ZIP archive with the following file structure:

-sandbox-[title].zip:
–/sandbox-[title]/
—- style.css
—- image01.png
—- image02.jpg
—- other-style.css
—- readme.txt
—- screenshot.png (400px by 300px)

A few important points before submitting your design:

  • Submissions containing a screenshot in a format other than PNG will be ignored.
  • Submissions containing a screenshot not 400px (w) by 300px (h) will be ignored.
  • Submissions in archive formats other than ZIP will be ignored.
  • Submissions lacking an explicit GNU General Public License license (or compatible) will be ignored.

Prize delivery

Results will be announced on www.sndbx.org by 12:00 AM (UTC), Monday, August 6, 2007. Winners will be issued their cash awards via Paypal within 48 hours of final results.

It’s interesting, isn’t it? Are you ready for this competition? :-) I will post some useful links for images, icons and sample css of sandbox theme.. Let me know if you have any resource that can be used for this competition. Feel free to discuss with me if you have any idea or comment about this competition.

All the best!!

[Weekly - QASW] – Questions and Answers in Software Development

Problem ~ Error while tryping to run project: Unable to start debugging on the web server. You do not have permission to debug the application. The URL for this project is in the Internet zone. Click Help for more information.

ASP.NET

I was getting this error recently when I was trying to debug ASP.NET 2.0 web project with Microsoft Visual Studio 2005 Professional Editor. Initially, I have no problem in debugging the web project in my machine. I think that the System Team made some security policies changes in my office. I did some experiments on this issue for some time and I found the following steps to solve this problem. Honestly, I’m not so sure which steps is the actual solution but I’m sure that this problem will be solved if you follow this step.

Solution ~

Step 1: Ensure that you account and ASPNET account is listed in Debugger Users group.

Step 2: ASPNET account has the permission to read (or write) your web directory.

Step 3: Add “localhost” or “*.local” in “Exception” panel of Proxy Setting. ( Internet Explorer>Internet Options>Tools>Connections>LAN Setting>Advanced button of Proxy Server>Exceptions>”Do not use proxy server for addresses beginning with ~”)

exception.png

Step 4: Add http://localhost to the trusted site.

Step 5. Run “iisrest” in Command Prompt

Then, it should work. If it doesn’t work, add ASPNET User account to Administrators Group. And try it again. I hope it will work for you. Feel free to let me know this solution doesn’t work for you or you know the better solution. Thanks.

———–

Problem ~ Visual Studio .NET has detected that the specified Web server is not running ASP.NET version 1.1. You will be unable to run ASP.NET Web applications and services.

aspnet-err.jpg

Solution ~

#1. Check the property of your web application. Most probably, your application is using ASP.NET 2.0 version instead of 1.1. So, you can simply change it to ASP.NET version 1.1.

#2. If it doesn’t work, run “aspnet_regiis” in command prompt.

Hope it will work for you too.

—————

Question ~ Why doesn’t C# support multiple inheritance?

Answer ~

The following is answered by Microsoft C# Team. The original post can be found here. I posted the copy here in case the original one disappears and I like this answer so much. ( Honestly, it’s kinda hard to understand. :) )

There are a number of reasons we don’t implement Multiple Implementation Inheritance directly. (As you know, we support Multiple Interface Inheritance).

However, I should point out that it’s possible for compilers to create MI for their types inside the CLR. There are a few rough edges if you go down this path: the result is unverifiable, there is no interop with other languages via the CLS, and in V1 and V1.1 you may run into deadlocks with the OS loader lock. (We’re fixing that last problem, but the first two problems remain). The technique is to generate some VTables in RVA-based static fields. In order to deposit the addresses of managed methods (which probably haven’t been JITted yet), you use the VTFixup construct. This construct is a table of triplets. The triplets consist of a token to a managed method, an address in your image that should be fixed up (in this case, a slot of the VTable you are creating in the RVA-based static), and some flags. The possible flags are described in corhdr.h and they allow you to specify 32- vs. 64-bit pointer sizes, control over virtual behavior, and whether some reverse-PInvoke behavior should be applied in the form of a thunk that eventually dispatches to the managed method. If we are performing an unmanaged->managed transition, you also have some control over which AppDomain should be selected for us to dispatch the call. However, one of these options (COR_VTABLE_FROM_UNMANAGED_RETAIN_APPDOMAIN) doesn’t exist in V1. We added it in V1.1.

There are several reasons we haven’t provided a baked-in, verifiable, CLS-compliant version of multiple implementation inheritance:

1. Different languages actually have different expectations for how MI works. For example, how conflicts are resolved and whether duplicate bases are merged or redundant. Before we can implement MI in the CLR, we have to do a survey of all the languages, figure out the common concepts, and decide how to express them in a language-neutral manner. We would also have to decide whether MI belongs in the CLS and what this would mean for languages that don’t want this concept (presumably VB.NET, for example). Of course, that’s the business we are in as a common language runtime, but we haven’t got around to doing it for MI yet.

2. The number of places where MI is truly appropriate is actually quite small. In many cases, multiple interface inheritance can get the job done instead. In other cases, you may be able to use encapsulation and delegation. If we were to add a slightly different construct, like mixins, would that actually be more powerful?

3. Multiple implementation inheritance injects a lot of complexity into the implementation. This complexity impacts casting, layout, dispatch, field access, serialization, identity comparisons, verifiability, reflection, generics, and probably lots of other places.

It’s not at all clear that this feature would pay for itself. It’s something we are often asked about. It’s something we haven’t done due diligence on. But my gut tells me that, after we’ve done a deep examination, we’ll still decide to leave the feature unimplemented.

————-

I found this question and answer below in codeproject forum that I used to participate. I think it’s very interesting.

Question : True and False – Best Practices

A few colleagues of mine are in disagreement as to what is the best practice for coding boolean flags. Should you use the actual words “true” or “false” or use the integers “1″ or “0″ (or -1 in some languages) respectively.

I favor a boolean flag to show values as “true” or “false” because it makes reading 800 lines of code easier. 0′s and 1′s can be confusing, in my scenario, because we are constantly setting variables back to a regular integer values of 1 or 0.

Thanks!

Answers ~

I believe you are right. In terms of readability if the language you are using actually supports the boolean type and the true,false keywords then it means is recommended to use them. In certain cases this will not be true. For example C did not have a book type until C99 came out and then C++ provided bool type and true/false keywords as a built in feature. If you do use C++ then it is recommended to use the true/false type since they are provided. Even in C , it was a good coding practice to #define the keywords TRUE and FALSE to 1 and 0 respectively to provide a more readable code.
Just my humble opinion

I agreed with this answer for this question. Why you wanna use 0 and 1 while Microsoft is providing the boolean type for us? :)

Related ~

Dark Theme is out – I love it!!

Wolfgang Bartelme’s “dark” theme is finally out. (The author is the one who created Freshy theme, very popular wordpress theme.) You all can download it here. I think this theme looks really great and I have been waiting this for very long time.

Dark Theme - Awesome WordPress Theme

It said,

The theme has been tested on WordPress 2.1.3 with Firefox and Safari, may play well with IE6/7 too. It validates as XHTML 1.0 Strict and CSS 2.0, and supports the following plugins:

* flickrRSS
* Gravatar
* Ultimate Tag Warrior
* WP-PageNavi

Download and Demo : http://www.ilemoned.com/wordpress/wptheme-dark

Thanks a lot. iLEMONed

Related ~