Sunday, November 18, 2012

Could not load type - The Structuremap Error

Recently I got an structuremap error when I launch my application. The error message as follows
Error Message: Exception has been thrown by the target of an invocation. - 0%System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> 
System.TypeLoadException: Could not load type 'MetricsEngine.ApplicationServices.Metrics.IMetricService' from assembly 'MetricsEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

at WebApplication6.Bootstrapper.Registries.ClinicalIntegrationRegistry.<.ctor>b__0(IAssemblyScanner scanner)
at StructureMap.Configuration.DSL.Registry.Scan(Action`1 action) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Configuration\DSL\Registry.cs:line 250
at WebApplication6.Bootstrapper.Registries.ClinicalIntegrationRegistry..ctor() in E:\Src\SolutionFolder\WebApplication6.Bootstrapper\Registries\MetricsRegistry.cs:line 33
--- End of inner exception stack trace ---
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at StructureMap.Graph.PluginGraph.ImportRegistry(Type type) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Graph\PluginGraph.cs:line 232
at System.Collections.Generic.List`1.ForEach(Action`1 action)
at StructureMap.Configuration.DSL.Registry.ConfigurePluginGraph(PluginGraph graph) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Configuration\DSL\Registry.cs:line 397
at StructureMap.Graph.AssemblyScanner.ScanForAll(PluginGraph pluginGraph) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Graph\AssemblyScanner.cs:line 249
at StructureMap.Graph.PluginGraph.Seal() in c:\BuildAgent\work\767273992e840853\src\StructureMap\Graph\PluginGraph.cs:line 121
at StructureMap.PluginGraphBuilder.Build() in c:\BuildAgent\work\767273992e840853\src\StructureMap\PluginGraphBuilder.cs:line 72
at StructureMap.ObjectFactory.Initialize(Action`1 action) in c:\BuildAgent\work\767273992e840853\src\StructureMap\ObjectFactory.cs:line 65
at WebApplication6.Bootstrapper.Bootstrapper.RegisterContainer() in E:\Src\SolutionFolder\WebApplication6.Bootstrapper\Bootstrapper.cs:line 27
at WebApplication6.Bootstrapper.Bootstrapper.Bootstrap() in E:\Src\SolutionFolder\WebApplication6.Bootstrapper\Bootstrapper.cs:line 20

Reason:

My project looks very similar to the following picture.
In the above picture, I am referencing two different dlls from two different sources with the same name "MetricsEngine.dll". Now during the bootstrap the structuremap supposed to load it's referenced assembly(0.0.4696.21382) which is from vendor1, but it loads the assembly (1.0.0.0) from vendor2 which is referenced by WebApplication6.EngineServices. Though both the assemblies had different public key token and different version, it always loads the one from vendor2. The reason is structuremap uses reflection to load the assemblies dynamically at runtime; it scans though current project's referenced assemblies and it's references and so forth. In that way assembly MetricsEngine.dll from vendor1 and vendor2 are considered by the structuremap, now it picks the latest version, in our case it picks 1.0.0.0. It doesn't care about assembly's identity (public key token).

Temporary Solution:

I tried, But I couldn't figure out the right solution. For time being after downloading the assembly I renamed the assembly manually and referencing it in my project. I uninstalled that package from NuGet. That is, I am not using NuGet for one of the referencing assembly. Once I figure out the solution I will update this post.

Tuesday, November 13, 2012

The Moore's law and the Core's question

Preface:

This article describes, what can be the next generation computer? Processor making companies like Intel keep reducing the chip size or they increase the efficiency in the same chip size in their every next release. The hardware improvement for every two years is an inevitable requirement. The software operating data size increases day by day, the gaming softwares require very good hardware acceleration. Now the chip companies couldn't reduce the chip size as they could before; they are shipping more than one processor in one suite; they call them as dual core, quad core and so on.

Moore’s Law:

The number of transistors on integrated circuits doubles approximately every two years. Wiki Link. Many have predicted that Moore's Law will soon reach its end.

The semiconductor is the problem:

There is a limit for reducing the size, since we know the processors are made up of silicon and germanium type semiconductors. They are solid, after certain level we can’t reduce their size. What could be the solution for next generation?

Solution:

As of now, there are two ways.
  1. The quantum chips.
  2. The bio chips.
The Bio chips can be made up of either DNA or RNA.

Quantum computer chips:

Rather than encoding ones and zeroes into high and low voltages that switch transistors on and off, the idea is to use the electron's spin. The Princeton and the Wisconsin university are the pioneers of this research. The electron spin has two directions; clockwise and anticlockwise. Scientists are making use of this spin and generating binary digits.

Earlier Version of the Theory:

The earlier version of this theory when I studied in 2004 uses a pair of electrons. In quantum mechanics two entangled particles cannot be viewed individually, even after they leave the interaction zone, where they became entangled. They act as a single quantum object. For example, there are two electrons e1 and e2. They can be used to express 4 different binary numbers.

Example:

To express decimal 14 in quantum computers we need two pair of electrons.That is from the above pictures,

Anticlockwise e1 + Anticlockwise e2 + Anticlockwise e3 + clockwise e4 = 14
Where as in conventional computer we need 4 transistors. That is,

Transistor t1 high voltage + t2 high voltage + t3 high voltage + t4 low voltage = 1110 = (decimal 14)

Transistors are not comparable with electrons in terms of speed and the space requirement.

The Modern Version:

The modern theory deals with electron’s superposition; hence by using single electron we can express 4 different binary numbers as follows.

Example:

In the modern version only two electrons are required to express decimal 14. From the above pictures,
Superposition state anticlockwise e1 + Superposition state clockwise e2 = 14

The conventional computer expresses in the unit of bit, in quantum computer it is qbit (quantum bit). In this case it requires 2 qbits.

Advantages of quantum computers:

  1. Size problem will go away, since electrons are super tiny. Also weightless.
  2. The speed, the current conventional PC’s are about 1-5 GHz speed, quantum computer’s speed will be at about 1-5 THz.
  3. It can be highly parallel computer, because of the electron’s superposition. Understanding electron’s superposition requires some effort, I am not covering here. For now, consider it is an electron's transitioning state

Challenges:

Computer’s speed cannot be improved only by improving processor. Other peripherals’ speed is also important. Scientists are working on them as well. Some researchers suggesting LASER for bus interface.

The DNA computers:

The idea is to use high and low concentrations of these molecules to propagate signals instead of high and low voltages that switch transistors on and off. It is medically proven that DNA can store biological information. Scientists are trying, if DNAs’ can be a better storage for computers? Can they be used for calculations?

The DNA (Deoxyribonucleic acid) contains nucleobases. The primary nucleobases are A, T, C and G. Adenine, thymine, cytosine and guanine are the expansion for them respectively. The DNA is a pair of strands. The strand is made up of strings A with T and C with G. Here is the basic concept for DNA computing.

In a conventional computer, in a bit you can store either 1 or 0. But in a DNA computer you can represent a bit by using these four variables. That is, it can be.

Example:

The same example to represent decimal 14 for DNA computers will be much more clear,
TAGC + TACG => 1110 => 14

Benefits of DNA computers

  1. One Kg of DNA can store the data from all the electronic computers ever built.
  2. DNA computer of half inch will be more powerful than supercomputers.
  3. In one cubic centimeter we can fit 10 trillion DNA molecules. With this size, a computer would be able to hold 10 TB of data, and perform 10 trillion calculations at a time.
  4. By adding more DNA, more calculations could be performed. Scalability! Also they can be highly parallel.
  5. DNA’s extracted from cellular organisms, there will always be a supply of DNA. So these computers will be cheap.

The RNA computers:

The RNA (ribonucleic acid) molecules are very similar to DNA molecules; the only difference is; RNA uses U (uracil) instead of T (thymine). Hence A, G, C and U are called RNA-bases. Everything above mentioned for DNA computers is also applicable for RNA computers.

What can cause an asp.net web service error?

Preface:

Last month I faced a problem in our production server that all the newly hosted websites threw javascript error. When I debugged further with firebug, I noticed that the web service calls were failing.

Reason:

Our website requires ABCpdf 8.1 but our server had version 7.0, that caused the error. Because in the latest release we upgraded ABCpdf to 8.1 in our development environment, but in the production environment.

Technical Details:

The error message was '/Site_URL/SampleWebService.asmx' has not been pre-compiled, and cannot be requested. I couldn't figure out the problem with the help of eventlog or application log. Google search also didn't help me. Finally I figured out that, the problem can occur when CLR tries to load any earlier revison of dll file, but the application was compiled with the latest version of dll. In this case the CLR failed to load ABCpdf 7.0.