To Register a C# COM Exposed Dll you I reccomend to create a Register.Bat file with the following instruction
------------------------------------------------------------------------------------------------------
REM Set the search directories
path=%path%;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319;C:\Program Files\Microsoft.NET\SDK\v1.1\Bin;C:\Program Files\Microsoft.NET\SDK\v1.1\Bin;C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322;
REM we first Unregister the .NET dll and then register it
regasm.exe /u "FullPath\MyLibrary.dll" /tlb
regasm.exe /codebase "FullPath\MyLibrary.dll" /tlb
pause
-----------------------------------------------------------------------------------------------------
This insturction set the search path for the regasm.exe file. I have included the most common directory that should have it
path=%path%; .......
This line unregister the Dll and its typelibrary
regasm.exe /u "FullPath\MyLibrary.dll" /tlb
This one creates the type library and register the dll with its full Path and along the type library.
If you do not use the /codebase option VB will complain that it cannot find the library.
regasm.exe /codebase "FullPath\MyLibrary.dll" /tlb
To unregister make an unregister.bat file
---------------------------------------------------------------------------------------------
REM Set the search directories
path=%path%;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319;C:\Program Files\Microsoft.NET\SDK\v1.1\Bin;C:\Program Files\Microsoft.NET\SDK\v1.1\Bin;C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322;
REM we Unregister the .NET dll
regasm.exe /u "FullPath\MyLibrary.dll" /tlb
pause
-----------------------------------------------------------------------------------------------------
When you use the code base option you need to have a strongly type Assembly (Dll) To do this
follow these steps
Go to Properties/Signing. Tick Sign the assembly check box.
Then go to Choose a stroing name key file
Choose a name ex "MyLibrary_COM_Key"
This will create a MyLibray_COM_Key.snk file in the project folder.
Lastly you also need to make sure that the Assembly Version is not someting like 1.0.* which means that each time you rebuild the project the assembly name changes. Just give the assembly a version, something like 1.0.0.0 and stick with it. The call to the COM exposed DLL is also connected to the assembly version registered in the registry.
Friday, September 10, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment