Now I run my program which crash because it can not find DLL1.dll in either the current directory or in the path. This causes a DllNotFoundException exception to be thrown. To handle this I have to catch this exception too. So I change my program a little bit as shown:

I also copy the DLL1.dll in the current folder to avoid this exception

Now again my program crash when I try to run it. This time it throws EntryPointNotFoundException. I should also catch this and display the error message of this exception rather than allowing the program to crash. Following is the new version of the program:

System.EntryPointNotFoundException: Unable to find an
entry point named Message in DLL Dll1.dll.
at MainClass.Message(String msg)
at MainClass.Main()

The problem is not in the C# program. In fact when you write the function in C++, the C++ compiler decorates the function name to get function overloading. The function which exports by DLL is not Message. To get the exact name type dumpbin -exports dll1.dll at the command prompt. Part of output of this utility is

ordinal hint RVA name
1 0 00001005 ?Message@@YGXPAD@Z

There isn't any standard way of decorating the function name. So you need to tell the C++ compiler to not decorate function name. Following is the revised version of DLL code:

extern "C" is used to tell the compiler not to decorate the function name. Now when you see the function name from the output of the dumpbin utility, it will look like this:

ordinal hint RVA name
1 0 0000100A _Message@4

Here @ shows that the function uses standard calling conventions and 4 shows the number of bytes push on the stack for parameters. In 32 bit environment like windows 9x and NT/2000 the address is stored in 32 bit i.e. 4 bytes. It means there is only one parameter in the stack. In other words this function take only one parameter.

Now the above C# program works fine without any change and display a message box with the text "Hello world" and the caption of "Message from DLL"

Let's do experiment with inline assembly in a DLL. I cannot call assembly language from C# but I know I can call an unmanaged DLL from C#. I made a DLL that calculates the speed of the CPU as well as determines the vendor name, Family, Model and Stepping of CPU using inline assembly language.

How can we do this in Internet Explorer

How can we do this in Internet Explorer.
I tried to do the same in IE using Usercontrol. But C++.dll is not getting at the client side. Other dll whicc created in C# using the UserContrl is getting in the CLient side. But on clicking Button to acces this dll(SysInfo.dll) to get the functionality shows ERROR -"dll not found exception etc".
So the question is how can we access a C++.dll to the client side.

Top White Papers and Webcasts

When individual departments procure cloud service for their own use, they usually don't consider the hazardous organization-wide implications. Read this paper to learn best practices for setting up an internal, IT-based cloud brokerage function that service the entire organization. Find out how this approach enables you to retain top-down visibility and control of network security and manage the impact of cloud traffic on your WAN.

U.S. companies are desperately trying to recruit and hire skilled software engineers and developers, but there is simply not enough quality talent to go around. Tiempo Development is a nearshore software development company. Our headquarters are in AZ, but we are a pioneer and leader in outsourcing to Mexico, based on our three software development centers there. We have a proven process and we are experts at providing our customers with powerful solutions. We transform ideas into reality.