Skip to main content

Exposing .NET as COM (Windows)

Below didn't work for me, so I'm trying these links instead:
http://www.codeproject.com/KB/COM/VS2005ComDllWalkThru.aspx
http://www.codeproject.com/KB/COM/VS2005RegisteringComDLL.aspx


Sorry, real world problem here - need to write it down:

(Ripped shamelessly from Experts-Exchange )

Ok, to make a VB Component COM callable, follow the instructions below:

1) Open up the Visual Studio .NET command prompt, and change to your project directory (where your .sln file is located). Whenever I refer to the command prompt, I mean the VS.NET command prompt. To open it, go to Start->Program Files->Microsoft Visual Studio .NET->Visual Studio .NET Tools->Visual Studio .NET Command Prompt. You may want to put a link to it on your quickbar.

In the command prompt, while in your project directory, type:

sn -k key.snk

This will create a strong name RSA key file with a public and private key. There are security implications if you create any components that are distributed outside your company, which we should discuss if you have this situation.

2) In your assembly's AssemblyInfo.vb file, create two attributes, which you can put right at the end of your file:

<Assembly: AssemblyDelaySign(False)>
<Assembly: AssemblyKeyFile("..\..\key.snk")>

Because the strong name signing of your assembly will occur on the Debug or Release assembly, you need to provide a relative path to your .snk file.

3) In your assembly project properties, go to Configuration Properties -> Build -> Register for COM Interop. Compile your assembly. This will create a .tlb file in the build directory that you can add into any VB or other COM clients for testing. This will also register the .NET assembly for testing on a development machine without having to use the following steps.

** If you are testing on your own machine, with the ASP in a local IIS server, you can stop now, and use the component using CreateObject("MyAssembly.Myclass"). ***

For server deployment, continue below:

4) Copy your Release assembly to whereever you would like on your server machine.

5) Make sure you have the .NET runtime installed on the server. I prefer not to install the entire SDK, but just the 20Mb redistributable.

6) Open a command prompt (regular, since only the SDK creates the special .NET one). Change the directory to:

C:\Windows\Microsoft .NET\Framework\v1.0.3705 (or whatever version of the Framework you are running)

7) Run "gacutil -i c:\where ever you put it\myassembly.dll" to install your component into the Global Assembly Cache. This is the simplest approach and does not require any special handling of your component.

If you have to uninstall from the GAC, just run "gacutil -u myassembly", without a path.

8) Run "regasm c:\where ever you put it\myassembly.dll" to have your component registered as COM callable in the registry.

If you have to uninstall from the registry, run "regasm c:\where ever you put it\myassembly.dll /unregister".

Now you should be able to call your DLL from COM.

Comments

Popular posts from this blog

Black Cursors on Win7/2008 R2 Using rdesktop for Ubuntu 10.04

I recently setup a Win 2008 R2 VM and proceeded to remote connect to it from Ubuntu 10.04. Everything worked perfectly except the mouse cursors were black (and some were corrupt). Solution? Use a newer version of rdesktop that doesn't ship with Ubuntu. There is a handy PPA that can be added using the following command: sudo apt-add-repository ppa:ricolai/ppa sudo apt-get update sudo apt-get install rdesktop [UPDATE] It appears ricolai may have removed the package from his PPA. To remedy the situation, I've uploaded the working binaries for x64. Sorry, I don't have the x86 any longer. More information on the bug can be found here: https://bugs.launchpad.net/ubuntu/+source/rdesktop/+bug/385974?comments=all

Getting the Hauppauge WinTV-HVR-2250 to work in Ubuntu 10.04

Really just posting this for my own reference later, but here's the link and the details: Enter this into your Terminal it is the code for the firmware and to install it Code: wget http://www.steventoth.net/linux/hvr22xx/22xxdrv_27086.zip wget http://www.steventoth.net/linux/hvr22xx/HVR-12x0-14x0-17x0_1_25_25271_WHQL.zip wget http://www.steventoth.net/linux/hvr22xx/extract.sh Code: sh extract.sh;sudo cp *fw /lib/firmware you need to install mercurial and build essential for the next steps Code: sudo apt-get install mercurial libncurses5-dev then we need the driver using this command to fetch Code: hg clone http://kernellabs.com/hg/saa7164-stable/ now change to the directory Code: cd saa7164-stable then run make Code: make CONFIG_DVB_FIREDTV:=n that will take some time, go grab a drink and wait it out, when it completes run this command Code: sudo make install wait for that to complete and reboot from the command line Code: sudo reboot Note that an application like TVtime will not

Mounting VMware VMDK Disks in Ubuntu (Linux)

Took me a while to find the info on this, but it's fairly simple once you piece together all the information out there. First off, I'm not converting this to VirtualBox. I'm simply accessing the HD as though it were mounted on my local file system (Ubuntu). The VMDK image is for a WinXP virtual machine. First off, verify you have vmware-mount on your system. Drop to terminal, type "vmware-mount". You should get info regarding usage. If not, you need to install VMware Server or VMware Workstation (it's bundled with them). When prompted during the install, say 'Yes' to installing the additional tools packages. Not sure which one it's in, but it's there. Sorry, perhaps someone else can clarify this point. Next, navigate to the location of your VMDK and type "vmware-mount -p .vmdk". This will show you a list of mount points within the file (first column). Create /mnt/ using "mkdir /mnt/ " Next, type "sudo vmware-m