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.
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.M
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
Post a Comment