rss search

next page next page close
next page next page close

Getting Version Number in Asp.NET

One of my recent tasks was to get Version Number information from AssemblyInfo.cs in Web Application project. So here I will try to explain what I did in order to accomplish my task:

There are several ways of doing this but I can’t say all of them are reliable methods. First methods I found are like the followings:

public static string Version {
    get {
        Assembly asm = Assembly.GetExecutingAssembly();
        FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(asm.Location);
        returnString.Format("{0}.{1}", fvi.ProductMajorPart, fvi.ProductMinorPart);

But the problem is what if your current method or your type is defined within another assembly and the method above will bring that particular assembly AssemblyInfo.cs information. But we specifically want our Web Application’s version number. If you are confused, think of it like this: You are working with types such as string, int, DateTime, Random class etc. They are all defined in an Assembly. So String is defined in System namespace which resides in mscore.dll and this DLL file has an assembly info data that describes some information about it such as VersionNumber, ProductVersion, etc. As long as all these assemblies are locating in searchable directories such as GAC, bin, etc. whenever a type is called, these assemblies will be searched and will be loaded to the Assembly Cache. So during programming life time, it may be hard to say in which assembly is the “ExecutingAssembly()”since you may define your method in different Assembly but want AssemblyInfo.cs of Web Project (consider there other class library project in your solution).

Anyways, long story short I’ve found the following code more reliable:

public static string Version {
    get {
        Assembly asm = typeof(ACustomClassDefinedInYourWebApp).Assembly
        return asm.GetName().Version;

A CustomClassDefinedInYourWebApp can be the class where you define the method above within. So you will always be sure that you have the correct Assembly to get its AssemblyInfo.cs.

Happy coding!

next page next page close

How to eat less

Eating too much?

Eating too much?

I don’t like eating too much as it makes me feel tired and heavy. So I look for common mistakes I might be doing while eating. If I know where I doing wrong, then I can fix it! I’ve recently found this article that I’d like to share with you. But I don’t like talking too much with same stories in different ways so I will just give the conclusion of a pretty long article:

The key player in all of this appears to be a region of your brain called the left posterior amygdala, or LPA. This area monitors the volume of food in your stomach during a meal. Fill your gut to a comfortable level, and the LPA tells your brain to drop the fork. Trouble is, it delivers that information at dial-up speed in a DSL world. “Many men consume calories faster than their bodies can say, ‘Stop!’” explains Herman. “So they look to external cues to guide their consumption. Please read the following:

The bottom line is this: To shrink your gut, you need to start listening to it. We’ve scoured the science and tapped the top experts to help you learn how to do just that. Use these seven simple strategies, and you’ll fill up without filling out.

  1. Sit Down: A 2006 Canadian study found that when people ate lunch while sitting at a set table, they consumed a third less at a later snack than those who ate their midday meals while standing at a counter.
  2. Don’t watch anything while eating: People who watched TV during a meal consumed 288 more calories on average than those who didn’t. The reason: What you’re seeing on television distracts you, which keeps your brain from recognizing that you’re full.
  3. Slow Down and Savor: “Pay close attention to those first three bites, which people usually wolf down due to excitement,” says Jeffrey Greeson, Ph.D., a health psychologist at Duke Integrative Medicine. In fact, mimic a food critic: “Examine the food’s texture, savor the flavors in your mouth, and then pay attention and feel the swallow,” he says. “Psychologically, this form of meditative eating boosts satiety and promotes a sense of satisfaction for the entire meal.” While you’re at it, try spicing up relatively bland fare, such as scrambled eggs, with hot sauce or smoked paprika. “Hot, flavorful foods help trigger your brain to realize you’re eating,” says Dorfman.
  4. Take a Bite, Take a Breath: University of Rhode Island researchers discovered that consciously slowing down between bites decreases a person’s calorie intake by 10 percent. “Breathing helps you gauge how hungry you are, since it directs your mind toward your body,” says Greeson. “It’s also quite practical, since you can do it throughout a meal and not draw attention to yourself in a social situation.”
  5. Don’t Trust the “Healthy” Menu: You’re likely to underestimate your meal’s calorie count by about 35 percent, according to a new study published in the Journal of Consumer Research. The best approach is to check the restaurant’s nutrition guide before you order. A University of Mississippi study found that people consumed 54 percent fewer calories when they used this simple strategy.

If you are happy to read all of the unnecessary words, then you are more then welcome at this address.

next page next page close

Why do we feel hungry too often?

There may be some simple solutions to help ease the hunger you are experiencing so the first thing I would suggest is to consider the following:

- Drink more water – dehydration leaves us feeling hunger even though it is water we need (the body interprets dehydration as hunger!). You need to be looking to consume two litres a day plus more to account for fluid losses during exercise.

- Consider when you are eating around your training. Ensure you are achieving ideal pre and post training nutrition. See the article titled “Can you explain about the timings for food and exercise?”, (dated Tuesday 18th September 2007), in the forum, you can find this by entering “Post exercise nutrition” into the ‘search forums’ tab on the forums page of the website. 

- Make sure you are getting adequate amounts of sleep as this affects energy levels and can leave us craving food as a way of offsetting the tiredness. Power naps during the day (just 10-30minutes!) are a fantastic habit to establish and are often easier then people realise to achieve.

- Consider your caffeine and sugar consumption – these can create energy highs and lows as our blood sugar levels rise and fall in response to these stimulants. The lows can leave us vulnerable to experiencing self-inflicted cravings for more sugar. Try to cut down or reduce such potential causes if you note these may be relevant to your personal situation.

If you were to try all of the above and did not notice any significant improvement in your ability to overt hunger then I would possibly suggest you re-check all your inputs for your exercise and food to make sure there are no slight miscalculations that could be leaving you with a daily calorie calculation that is actually slightly too low for your requirements. The likelihood of this is quite low and normally the above factors have more influence then we give them credit for but just in case it is always good to thoroughly re-assess all elements of your plan

next page next page close

Death and Evolution

It is almost like whenever I check the Turkish News, I see a well-known, famous singer, anchorman etc. lost their lives. Last time I checked the news, I saw Muslum Gurses passed away. Whether I liked his style or his songs is another discussion but it reminds me one BIG  thing, how short our lives is. Like many of famous people in Turkey, he had a hard times when he was a kid. He struggled a lot (at least this what media says about this early life).After they became famous, it seems they had a pretty decent life in terms of money, fame and all the worldly matters. But like every one else, they left all this fame and rich life behind and went somewhere else we yet to see. Where did they go? It might be a BIG question for many of us. Some people don’t believe the fact there is a after life where some believe. Even for some people, their whole purpose of this life is to prepare for afterlife as they believe it is the final and true destination.

It is hard to believe in the fact that if there is no afterlife, all these people and their lives will be wasted whereas everything is based on a economic recycling (e.g nothing is wasted in this Universe, everything is recycled in some way). Well, we can assume that our bodies will be recycled in some way and maybe we will become a fruit :) but what about our feelings, our passion, love, laugh, hatred, etc. Just because we don’t see them doesn’t mean they are not real. We all know they are real as we are feeling them in somewhere in our heart. Does the word “Nothing” also include “feelings” as “Nothing is wasted”?

All these deaths reminded me my purpose of life and caused me to ask myself all these questions:

  1. Who am I?
  2. Where did I come from?
  3. Where am I going now?
  4. What’s my purpose?

I used love sweet things such as chocolate, cake etc. I still like them but I hardly eat a small piece of them a day while I would be able to eat whole plate when I was a kid. After after a while, this idea got me thinking the fact that “it seems eating good food and getting satisfied is not the purpose of life”. But why do I have the ability of eating and savoring the taste of all these different tastes? Just for this, these are what I need:

  1. An advanced tongue which can handle the food in my mouth and proceed some chemical reactions in order to send the taste messages to my brain.
  2. A very efficient and effective so highly advance lines (neurons) which can transmit the message so quickly that makes us feel like we are perceiving the taste as we chew our food.
  3. A brain where all these messages can be interpreted and deciphered so I can feel what I am chewing. Of couse it also needs to react to well since what I am eating might be something bad, so the brain can reject it and alerts all the necessary parts of my body.

If a car doesn’t take you to your work, or your vacation destination, etc. then it is meaningless. So I use a car in order for a greater good. Buying a car just because it is a car would be silly idea. Could it be that we buy all these tools for a great good. Oh wait we didn’t buy them, they evolved, right?! They randomly evolved to become such complex entities. An unconscious evolution surpassed the very conscious people’s brain as they still cannot understand all these amazingly complex yet remarkably efficient structures.  For statically speaking, the evolution of a simple eye (I am not sure how simple it is though :) ) would take a trillion years or more but “Hey! it takes only several millions years, how awesome is that!”.

Lets get back to main subject. We all know that all the books have a preface in order to explain what it is all about. It warms up the reader for the actual book and says “Hey reader! If you like this preface then wait for the actual content. You will absolutely love it and enjoy more!”. So reading preface all the time and ignoring the book would be awkward! For some reason, I found a similarity between a preface and all the capabilities I have in my body. It seems I have a preface of something better. If I get tired of eating a cake over and over again, my tongue says me “I am here to show you that there might be something better later if you like what you’re eating now. But don’t get stuck with this cake and go ahead and flip the page over.”

But unlike books, we seem to not be able to see the actual book in this world. Everything I have gets bored after a certain limit and whatever I try doesn’t make me satisfied. So when I flip the page over, the previous page gets lost from my sight. But in order to keep reading, I have to flip it over. And death looks like flipping the page over. It says “I am done with this page, so lets go ahead and read the book.”

What if I was given that book and I said “I don’t like this preface, it looks horrible” just because I couldn’t understand it (not requested any help from some one else who could give me an explanation)  and I ripped off the whole page? Would The owner of the book be really angry with me? I am 100% sure that he would and he would take his book back as I don’t deserve it and I would not be able to enjoy the following pages. What if our lives are like this? What if we were told that “Read the preface and enjoy it and thank the Author so you can read the following pages and he will also give you a hand,etc.”

We are so eager to follow patterns and explain this with its creator, for example a book cannot be a without a author and we praise the author when we like the author. But I don’t understand why we change our so logical perspectives when it comes something very similar but a lot bigger?

next page next page close
A Pen A Pen zoom
next page next page close

Responses to Conflict in Individualistic and Collectivistic Societies

Osman Senkaya

Cultural differences have a potential to trigger conflicts at all levels, and the response each society gives to these conflicts depend on what they hold most dear as a foundational norm: independent existence of individuals or social interdependence. This calls for awareness in differences and discussion to benefit from cultural diversity.

Michael was having a problem with his neighbor next door. He decided to seek advice from his coworkers on the issue. Paul suggested that he express the problem openly right away, and, if that wouldn’t help, to take the neighbor to the court. Akihiro, on the other hand, warned him not to get too serious, and recommended him to write a letter which talks about their good memories in the past and how pleasant their neighborhood was. The backup plan in this case would be to invite a mutually respected neighbor of theirs to mediate the situation.
Of course, Michael has many other options to address the given problem. Yet, it is interesting to note the differences between the suggestions of the two coworkers. One party is focused on the issue per se and pursues a direct approach; whereas the other is concerned about the relationship and follows indirect/accommodating means to handle the situation. This article is intended to provide a better understanding of these two main approaches in conflicting situations. Since the responses to unease are generally situational, we may not judge whether any of the resolution efforts are good or bad, but rather, look closely on their rationale respectively.

Cultures differ on various aspects of life. Naturally, the approach of their members to conflict will also vary depending on the value they place on issues of interest and dominant cultural characteristics. A close examination of these features in a given society will give an idea on how its members would respond to conflicting situations in general. Given the growing interconnectedness of societies today, such knowledge of cultural tendencies might help in the development of strategies for conflict resolution and prevention.

Societies that promote independent existence of individuals are referred to as individualistic, and those which assume a great deal of social interdependence are grouped as collectivistic cultures.1 Prior to discussing responses to conflict in these two types of cultures, it may be better to highlight some examples of their interpretations which will provide hints about their foundational norms.

He who hesitates is lost. (American expression)
Strike while the iron is hot. (American expression)
More haste, less speed. (Chinese expression)
A deliberate inaction is better than a blind action. (Chinese expression)

Different cultures may have different viewpoints about the same issue. This affects the responses of their members and the methods they favor in various situations. Existing theories in social sciences, which generally reflect social values of individualism and autonomy, may be inadequate in societies that do not share the same values and foundational norms, and vice versa. Such a cross-cultural analysis requires an understanding of the prevalent cultural values and norms in a given society.1 These shared values, through which cultures develop and continue, are communicated in a variety of ways. One technique that commonly appears is the use of proverbs or sayings, and such quotes throughout the commentary will provide a general idea about some differing characteristics of these two cultural approaches. 

Rather than criticizing or promoting any specific cultural aspect, this piece aims to discuss another dimension of multicultural approach to serve to break the stereotyped images (if any) about different cultures, and to help accept everybody as they are in a world of cultural diversity. Once we have a broad picture, we will further look into how interpersonal conflict is handled, and conclude with some overarching suggestions to foster mutual understanding in cases of unease.

Two’s company, but three’s a crowd. (American expression)
If you congregate, you live. If you scatter, you die. (Korean proverb)
One who leaves the herd, gets snatched by the wolf. (Turkish proverb)
One palm makes no applause. (Chinese proverb)

Two widely held worldviews have become evident in the cross-cultural literature as variables on which most cultures vary: individualism which objectifies the self, and collectivism which submerges the self to emphasize the group. A middle course in the de bate between those who claim the primacy of society and those who emphasize the primal significance of the individual would state that there is no society without an individual; and also that no individual can survive without society.2 These concepts do not necessarily form opposite poles and may coexist due to the enormous intercultural mix, yet one approach may still have dominance to the other in a given culture.3

“The freedom to be an individual is the essence of America.” (Marilyn vos Savant)
“It is hard to be an individual in Japan.” (Haruki Murakami)

In individualistic societies, a person is an autonomous entity defined by a somewhat distinctive set of attributes, qualities, or processes; and these internal attributes determine the behavior. Yet, in collectivistic societies, a person is an interdependent entity who is part of the encompassing social relationships. This is not to say that a person in such a society lacks unique attributes, but rather that these are not primary forces that guide the behavior. In such societies, behavior is a consequence of being responsive to others and origins of behaviors are relationships and social harmony.3

He who converses not knows nothing. (English proverb)
He, who knows, does not speak. He, who speaks, does not know. (Lao Tzu)

In Western cultures, a highly verbal individual is perceived more positively, whereas in Eastern cultures perceptions for highly verbal individuals may not be that positive. Traditionally, communication apprehension has been attributed to a weak sense of identity and is viewed as a deficiency; but on the contrary, this reticence may be due to politeness or a tendency to preserve harmony in collectivistic cultures, depending on the social context.

Stand up for your own rights. (American expression)
Unless you blow your own horn, who will? (American expression)
Once you preach, the point is gone. (Zen phrase)
Mature rice plants bow down lower. (Korean expression)

According to individualistic point of view, communicators can get things done by being assertive. On the other hand, from the collectivistic standpoint, people are expected to preserve group identity and may be discouraged from asserting themselves as individuals. Therefore, it will not be a true assumption to attribute this lack of assertiveness to some negative traits such as low self-esteem, shyness, disinterest, or ignorance.3

Cultural dimensions of conflict resolution
“The practice of peace and reconciliation is one of the most vital and artistic of human actions.” (Nhat Hanh)
Keeping all the above examples in mind, now let’s briefly compare and contrast responses to conflict in individualistic and collectivistic societies:
Since individuals’ self-articulated interests are of utmost importance, individualistic perspective frames conflict as the divergence of interests or issues, which limits the focus of solution efforts solely to reconciling the differences in interests between parties. Yet in collectivistic cultures, social harmony is a critical aspiration and community involvement is likely even in interpersonal matters. Then, a deeper and wider analysis that will address the concerns of both types of approaches should better view conflict as a situation and place the situation to the heart of any resolution endeavor.1
“He who wants to persuade should put his trust not in the right argument, but in the right word. The power of sound has always been greater than the power of sense.” (Joseph Conrad)
The one who raises his/her voice has already lost. (Japanese proverb)
Members of individualistic cultures tend to prefer direct/dominating/prompt communication styles, since they deem open discussion as the best way to deal with their interpersonal problems. On the other hand, individuals in interdependent societies are less likely to “express negative emotions (such as anger) to confront each other, and to use verbal aggressiveness and open discussion in conflict situations. They may avoid reactions to their relational problems that can potentially cause further conflict”. Among them, the stress is not so much upon the individual and his/her interests, but on the maintenance of the collectivity and the continuation of harmonious relationships; conflict is viewed as damaging to social fabric and relational harmony, so it should be avoided as much as possible. This naturally leads to the adoption of high compromising and avoiding behaviors and a relatively low preference for competing and assertive postures which emphasize the value they place on maintaining social harmony rather than personal interests in conflict interactions.3
“Peace is not absence of conflict; it is the ability to handle conflict by peaceful means.” (Ronald Reagan)
There is a natural tendency to avoid conflicts as much as possible. While it is a major strategy to preserve harmonious relationships in Eastern cultures, Western societies may view accommodation efforts as giving up critical values and personal rights. Furthermore, according to the Western approach, people will prefer to avoid conflict only if their stake in an issue is not high enough to get involved, whereas collectivist cultures actually utilize it as a social remedy.3
In collectivistic societies, “understanding is seen not as the result of putting meaning into words, but rather as the greater understanding of shared perspective, expectations, and intimacy”, and avoidance is utilized as a strategy to handle the conflict. Besides expressing the discomfort indirectly/nonverbally in a polite and educating way, non-confrontational communication modes in problematic situations include, but are not limited to: “(a) the use of management to prevent a conflict before it happens, (b) expression of conflict emotions like anger or frustration by non-communication, such as ignorance or silence, (c) pretense of being harmonious in peoples’ presence, even though parties are actually avoiding each other, (d) management of conflict using a third party, (e) tendency of directing accusations against oneself.”3
Cultural differences in third party intervention
“The Believers are but brothers; so make peace and reconciliation between your brothers… ” 4
How, when, and why a third party interferes has been the central focus of conflict resolution studies. Models on interpersonal conflict that assume a great deal of individual autonomy and privacy in interpersonal matters hardly speak about engaging one’s social network into a conflict, however interpersonal conflict intervention in a collectivistic setting will not take place only between contending individuals and the intervener, but is likely to engage other entities (e.g. extended family members) almost in any given conflict. This involvement of others, with the purpose of securing, improving or sustaining a resolution, can be added strength for conflict intervention and resolution.1
“Washing one’s hands of the conflict between the powerful and the powerless means to side with the powerful, not to be neutral.” (Paulo Freire)
Western literature on interpersonal conflict intervention generally undermines the adjustment of the involvement style depending on the stage of the disagreement. However in collectivistic societies, “third parties are expected to function in a reconciliatory mode, unless clear injustice or deviance takes place. In this case, third parties should get actively involved in restoring justice and eliminating deviance before returning to the reconciliatory role.” Consultation may be utilized “when relationship issues (perception and attitudes) are not suitable for mediation, and to help parties clarify their underlying needs (security, or identity for example) and interests tied to such needs. Mediation, on the other hand, aims at negotiating certain substantive issues, based on a clear understanding of relationship issues and parties’ own needs and interests.” 1
Adhering to the common good while not favoring any of the parties has good intentions, yet the mediator may face difficulties in modern diverse societies, where notions of common good may be too diverse and vague; focus being on the individual. Material resources are often the codes used, thus legal procedures are vital parts of the resolution in these societies, and mediators are expected to be professionals who are knowledgeable of legal procedures. Thus, actions in a resolution process are task-oriented. Conversely in collectivistic societies, where the main focus is on social harmony and social norms/values form the basis of a solution, mediators are generally seniors (in terms of age or hierarchy) who are knowledgeable of cultural norms. Some codes mainly used by interveners in these cultures include honor, dignity, unity, future of the next generations, religious values, and tradition of forgiveness.1, 5 
Speaking of religion and its role in conflict, one’s voluntary sacrifice from his/her rights in some conflicting situations, repelling evil with what is better,6 and forgiveness has been encouraged for thousands of years by major world religions.7 “Adherents of these religions have claimed that forgiveness yields numerous emotional and spiritual benefits, and can dramatically transform one’s life.”8 Hence, it may be useful to explore their resources, which are rich with conflict intervention principles, values and models, in a way that would prepare them for contemporary practice. For instance, it is stated that reconciling a dispute between two parties is a charity,9 and that “kind words and forgiving of faults are better than charity followed by injury.” 10
The most beneficial approach for the involved parties in a conflict situation would be an attempt to address fully the concerns of both parties and to find mutually satisfactory solutions to the cause of the conflict. This collaborative approach is of utmost importance and most viable, particularly when the issues are critical and maintaining an ongoing relationship is important. For an effective assistance, third parties involved in mediation processes should carefully study the needs and values of contending parties and have cultural awareness in order to provide mutually satisfactory resolution options regardless of the society they operate. 
Considering that disagreements could be resolved much easily when parties are aware of corresponding needs/values and interests/concerns, getting to know one another would be an important basis for any resolution endeavor. Therefore, the more we exchange ideas without prejudice, the more we’ll understand each other. Although some disagreements yield positive outcomes and new ideas, intense conflicts generally drain energy and resources. Hence, it is heartening to observe that peace studies such as conflict resolution are blossoming, despite some scholars expecting a “clash of civilizations” and some claiming that we are at the “end of history.” Contrary to the arguments that define life as a series of struggles for limited resources, this relatively new field of social sciences will help humanity make the best out of its potential and reach a better state of living. Comprehensive resolutions which are globally applicable to disagreements in-between individuals, organizations, or nations overall, call for good deeds, positive motives, and pure intentions without self-interest. Tolerance, forgiveness, altruism, compassion, submission to ethical/moral codes, fairness, openness of hearts and minds, and welcoming people as they encompass some of the universal means to cure conflicts at various levels. 
1. Abdalla, Amr. 2000. “Principles of Islamic Interpersonal Conflict Intervention: A Search within Islam and Western Literature.” Journal of Law & Religion 15, no. 1. 151-184.
2. Nasr, Seyyed H. 2002. The Heart of Islam: Enduring Values for Humanity. San Francisco: HarperCollins.
3. Kim, Min-Sun. 2002. Non-Western Perspectives on Human Communication: Implications for Theory and Practice. Thousand Oaks, Cal.: Sage Publications.
4. Qur’an, 49:10.
5. Abu-Nimer, Mohammed. 1996. “Conflict Resolution in an Islamic Context: Some Conceptual Questions.” Peace and Change 21, no. 1. 22-40.
6. Qur’an, 41:34.
7. For some of the Qur’anic verses on interpersonal forgiveness and reconciliation not mentioned in the text, the reader may refer to 2:280; 3:134, 4:128, 135, 149; 24:22; 25:63; and 42:37, 40, 43.
8. McCullough, Michael E., Kenneth I. Pargament, and Carl E. Thoresen. 2000. Forgiveness: Theory, Research, and Practice. New York: The Guilford Press.
9. Bukhari, Sulh, 11; Muslim, Zakat, 52.
10. Qur’an, 2:263.

next page next page close

Inversion of Control in a Nutshell

Inversion of Control is a software design in which objects are bound together at run time. They are not known during compile time. There are several type of inversion of control:

  1. Factory Pattern. A class method accepts a parameters in order to return requested object after initializing it.
  2. Service Locator Pattern.
  3. Dependency Injection.
    • Constructor Injection like in Asp.NET MVC
    • Setter injection like (Properties in C# and setter method in Java)
    • An interface injection.

In dependency injection, a class requests all the dependent objects via constructor parameters and assign them to a private field.

public class Samurai {
    public IWeapon Weapon { get; private set; }
    public Samurai(IWeapon weapon) 
        this.Weapon = weapon;

and Binder/Assembler instantiates the class Samurai, passes in Weapon concrete object (instantiated). As you see you don’t have any control over when the object will be created so this means you gave the control to the IoC Framework instead of instantiated it in your class at your will.

But there must be a place where you need to tell which types should be bound to which type. That’s why modules are here. Each DI Frameworks might have their own way doing this but as we are using NInject here  the following code shows the class where we tell the Framework binding instructions:

public class WarriorModule : NinjectModule
    public override void Load() 

As you can see we’re telling the framework to bind Sword class to IWeapon so when we need an weapon, FW will inject Weapon object.

So as you can see there are several benefits of doing Inversion of Control using Dependency Injection:

  1. When you need to change the implementation details by changing the concrete class, all you need to do is to change the binding in the module instead of changing it everywhere in the project.
  2. It gives you more centralized location where you can manage your bindings.
  3. Whenever you need a new object, all you have to do is to request from within method parameter and you will have it.

Sample codes are taken from, an open source library.

next page next page close

Managed Modules and Assemblies

It is hard to find concise blog post these days as people like talking too much some times :) so I will try to give your concise explanation about these two, Managed Modules and Managed Assemblies.

1. Managed Modules are compiled code containers which means they contain IL code and along with PE32 header,CLR Header, Metadata. CLR ignores PE32 headers though. They are not usable by themselves so they need to be a part of an Assembly in order to be useful in other applications. A netmodule can not be deployed alone. It has to be linked into an assembly.  You can use AL.exe in order to link may managed modules in one assembly. C# compiler only compiled one .net module in one assembly which is called single file assembly.

About Managed Modules, I’ve found this article really nice so I would like to share some excerpt from it:

A managed module consists of two very important sections: Metadata: describes the layout of classes, members, attributes, etc. Managed code: CIL methods, global data, etc. (This is optional.)
The astute reader will notice that I have left out two other bits of information that also form a managed module: portable executable (PE) header (Windows. Informs Windows which version of the OS it needs to run, and other things like whether or not it uses a command line interface (CUI), or graphical user interface (GUI), among other things); and the CLR header (this determines which version of the CLR should be loaded into the process). In this article we will ignore the PE and CLR headers and concentrate on the metadata and managed code sections of the managed module.

2. First understand what assembly means in literal manner :  ”The process of building something by putting all its parts together” or a “meeting of people who represent different parts of a large organization” (Macmillan). I strongly recommend you to understand the literal meaning before diving into what it means in .NET. So we know that it is something composed of many different parts coming together. Good news! It is something similar to what we use them for within .NET.

Please check this diagram first:

Assemblies might be composed of Managed Modules, Resources using AL.exe (Assembly Linker)

Assemblies might be composed of Managed Modules, Resources using AL.exe (Assembly Linker)

Assemblies contain Assembly Manifest which is something managed modules don’t have. Assemblies are containers which contain managed modules, resource files such as png files etc.

But most of the time, assemblies are composed of only one Managed Module and nothing else. Visual Studio is only capable of putting one managed module in one assembly and resource files if requested specifically.

If you want to add more managed modules in one assembly, then you need to use command prompt and /addmodule flag.

Assembly Manifest is an important thing we should know, it contains all these data defined here.

There is single file assemblies as well as multi-file assemblies:

Single File Assembly

Single File Assembly


and multi-file assemblies:

Multi file assemblies

Multi file assemblies

And I am taking this description from MSDN:

In the illustration above, the developer of a hypothetical application has chosen to separate some utility code into a different module and to keep a large resource file (in this case a .bmp image) in its original file. The .NET Framework downloads a file only when it is referenced; keeping infrequently referenced code in a separate file from the application optimizes code download.

I hope it is helpful to you, you can see my actual note here on my Evernote page.

As a summary,

Don’t bother yourself with managed modules since most of the time, you won’t use it. Understand how assemblies work but of course you need little info about the things which makes up assemblies. Assemblies are used most of the time in our daily lives as they are being used by CL R or Mono Run Time. So when you share you code, you share the assembly file Visual Studio created for you.


next page next page close

How to inject exception data to Razor View

First lets get things straight,

If you want to inject Exception Data into the view page, you would use “redirectMode=”ResponseRewrite” and the reason is if you used “ResponseRedirect”, then you would end up losing all the exception data you wanted to inject. ResponseRewrite uses Server.Transfer method in order to change the page to the error page. But Server.Transfer doesn’t work with MVC routes as it looks for physical page in a file system and we don’t deal with physical pages but actions methods here. You can use a physical page but this time we need to use either Asp.NET Web Forms page (not MVC) or an html page in that we cannot render actual error description.

Well, most of the time, for security reasons I don’t recommend you to show stack trace and exception description but you can use something like below in order to show the exception in DEBUG mode:

  //show your stack trace and other exception data here 

Please remember! Using #IF DEBUG directive in Razor Views are useless. You can find more info about it here.

This is the solution I’ve found nice but of course I would be more than happy if you share your awesome solution too:

I am using Application_Error event handler within Global.asax. This is fired every time an error occurs so I can easily deal with what ever is thrown :

I am too lazy to write the whole code from scratch so I copied the sample codes from this address here.

protected void Application_Error(object sender, EventArgs e)
    if (Context.IsCustomErrorEnabled)

private void ShowCustomErrorPage(Exception exception)
    HttpException httpException = exception as HttpException;
    if (httpException == null)
        httpException = new HttpException(500, "Internal Server Error", exception);

    RouteData routeData = new RouteData();
    routeData.Values.Add("controller", "Error");
    routeData.Values.Add("fromAppErrorEvent", true);

    switch (httpException.GetHttpCode())
        case 403:
            routeData.Values.Add("action", "AccessDenied");

        case 404:
            routeData.Values.Add("action", "NotFound");

        case 500:
            routeData.Values.Add("action", "ServerError");

            routeData.Values.Add("action", "OtherHttpStatusCode");
            routeData.Values.Add("httpStatusCode", httpException.GetHttpCode());


    IController controller = new ErrorController();
    controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));

In the code above, we simply handle our error gracefully and inject the data as Route Data into our Controller class which looks like the following:

public class ErrorController : Controller
    public ActionResult ServerError()
        return View("Error");

    public ActionResult AccessDenied()
        return View("Error403");

    public ActionResult NotFound()
        return View("Error404");

    public ActionResult OtherHttpStatusCode(int httpStatusCode)
        return View("GenericHttpError", httpStatusCode);

    private class PreventDirectAccessAttribute : FilterAttribute, IAuthorizationFilter
        public void OnAuthorization(AuthorizationContext filterContext)
            object value = filterContext.RouteData.Values["fromAppErrorEvent"];
            if (!(value is bool && (bool)value))
                filterContext.Result = new ViewResult { ViewName = "Error404" };

Well this is all. I am sure you are smart enough to understand what this code means but in case you don’t , then please leave a comment so I can answer. I don’t like talking too much but this solution helped me when I was having some trouble converting some Error.aspx file to Error.cshtml while keeping the same functionality.

next page next page close
next page next page close
My wife knows how to make cake! My wife knows how to make cake! zoom
next page

Future is near! LeapMotion 3D Controller

All that controlling computers without touching any device technology is finally...
article post

Getting Version Number in Asp.NET

One of my recent tasks was to get Version Number information from AssemblyInfo.cs in Web...
article post

How to eat less

I don’t like eating too much as it makes me feel tired and heavy. So I look for...
article post
There may be some simple solutions to help ease the hunger you are experiencing so the...
article post

Death and Evolution

It is almost like whenever I check the Turkish News, I see a well-known, famous singer,...
article post
thumbnail A Pen article post

Responses to Conflict in Individualistic and Collectivistic Societies

Osman Senkaya Cultural differences have a potential to trigger conflicts at all levels,...
article post

Inversion of Control in a Nutshell

Inversion of Control is a software design in which objects are bound together at run...
article post

Managed Modules and Assemblies

It is hard to find concise blog post these days as people like talking too much some...
article post

How to inject exception data to Razor View

First lets get things straight, If you want to inject Exception Data into the view page,...
article post

What is Schema in SQL Server

In this video, the author explains what schema is in SQL Server 2008.
article post
thumbnail My wife knows how to make cake! article post