Create clock.cs:

public class Clock
     public System.String Now()
	return "Don't know the time";

compile using:

csc /t:library clock.cs

Create cc.cs:

class cc
    static void Main()
	Clock c = new Clock();
	System.Console.WriteLine( c.Now() );

compile using:

csc /r:clock.dll cc.cs

Run cs.exe

In order for cc.exe to find clock.dll, they must be in the same directory. However, clock.dll may be made into a shared component by installing it in the global assembly cache:

First create a private key:

sn -k orgKey.snk

The recompile the .dll with this public key:

csc /target:library /a.keyfile:orgkey.snk clock.cs

And finally, install the the assembly in the shared assembly cache:

al /i:Clock.dll

To later remove the assembly from the cache, run:

rundll32 fusion.dll, RemoveAssemblyFromCache clock

or right click delete in c:\windows\assembly

Alternative to using "al", is:

rundll32 fusion.dll, AddAssemblyToCacheA -m clock.dll -p


dumpbin /exports on fusion.dll

to see a list of other commands.

To create a .reg file which will register the .dll as a COM object run:

regasm /regfile:clock.reg clock.dll

To create a .tlb file which can be used to access the COM object from VB or C++ run:

regasm /tlb:clock.tlb clock.dll

To simply register the DLL as a COM object, type:

regasm clock.dll

To unregister type:

regasm /unregister clock.dll

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.