Regisering a Dll written in C# on a windows server machine - (Install a C# Class Library)
Asked Answered
H

2

1

I have written a save and open dialog box add on for a VBA project i'm working on - heres the link VBA: Get Excel FileDialogOpen to point to "My Computer" by default (thanks for the help @mehow).

Now this add on (Class Library as it is actually called) works fine with the vba project on my computer which Ive been developing it on. However now to use this add (Class Library) on on the server I'm not able to get addon registered successfully so that the VBA project can see it.

I wrote the Dialog box add in in C# with VS 2013 Express for Desktop on my Windows 8 machine and we are now trying to test it on a windows server 2008 machine where the VBA project will run at the end of the day.

I have tried using the regsvr32 command on the server as well as looking for a deployment option in VS 2013 but neither seem to be working! I have also tried searching for a solution but no luck so far.

If anyone has any ideas how this can be done it would be much appreciated. Sorry if i'm not using the correct terminology. . . add ins etc but I hope you get what I mean.

Many thanks

Tristan.

Heterotrophic answered 26/11, 2013 at 15:25 Comment(5)
Have you tried regasm /i /codebase yourAssembly? Is your assembly (and type) ComVisible?Frodi
This is the first time i have used VS etc and needed to register dlls etc so am not at all clued up on it. But looking into the vs project properties there is a ComVisible box checked. How exactly would i go about egasm /i /codebase yourAssembly? Thanks.Heterotrophic
Oh sorry, ignore my comment. It seems that regasm is only installed as part of VS or Windows SDK, so it's probably not inteded for production use. You can use the command on your own computer to generate a reg file you can run yourself, ie. open Visual Studio Command Prompt, run regasm /regfile /codebase yourAssembly.dll. This will produce a reg file you can add to the registry on your target computer. I have had some issues with that though, so it might not be enough. Also note that you can only use the /codebase flag if your assembly is signed.Frodi
Hi @Luaan, I have been trying to get this right but no luck so far. With 'yourAssembly.dll' does this include the path to the dll? What do you do with spaces in the path the cmd environment doesn't seem to like them? Also do i need to do anything to this file from VS's side first? do you know of a link or something i can follow? ThanksHeterotrophic
You have to enclose the path (including the filename) in quotes, ie. "C:\Program Files\MyApp\MyDll.dll" etc.Frodi
H
3

I finally seem to have gotten this to work after trying all kinds of different methods so I'm not sure this is all you need to do but hopefully it can help someone in the future.

Firstly, Visual Studio 2013 Express does not include "Setup Projects" so you are not able to create deployment pacages in it for use in installing your project on other machines so you have to do it manually.

Then you are also going to need the same .Net framework on your target computer as you used to write your project in - this is a no brainer if you think about it but work checking.

So i copied the .dll, .pdb & .tlb files from the Visual Studio projects bin\Debug folder on my development PC and put them into a folder on the servers C: drive.

Then opened command prompt as administrator (by right clicking on the icon in the start menu and clicking "run as administrator". Then navigate in command prompt to your destination PC's .Net folder by using cd C:\Windows\Microsoft.NET\Framework\v4.0.30319 folder you will find "

Once there i ran regasm /codebase "C:\MyClassLibraryFolder\MyClassLibrary.dll" and regasm /tlb /codebase "C:\MyClassLibraryFolder\MyClassLibrary.dll" and this seemed to register everything and let my VBA project run on the server using the MyClassLibrary.

From my reading regasm is installed with .Net 4+ (and if found it in this folder on the server) and gacutil seems to be no longer included and when i tried to run it on the server by copying it across it didn't seem to do anything.

If this does not work i also did ran these commands so they might have added to the win regtlibv12.exe found at Register type library x64 regtlib which also mentions Regasm /tlb

And this link is similar as well Using C# Class Library On Non-Development Machine

For info on regasm - http://msdn.microsoft.com/en-us/library/tzat5yw6%28v=vs.110%29.aspx

Hope this helps.

Thanks all for your suggestions.

Heterotrophic answered 1/12, 2013 at 13:12 Comment(1)
+1 Tristan very good description. One thing - you probably do not need the .pdb :)Lymphangitis
E
1

If you want to register .dll you need to put it in assembly - C:\Windows\assembly

To do so you need to use gacutil.exe utility and execute

gacutil.exe /if Your_dll_name.dll
Eames answered 26/11, 2013 at 15:29 Comment(2)
Hi @Nogard, thanks for helping out. Would i then run this on the server or on my development machine? i need to install this dll on the server which does not have VS etc. From the documentation i read regarding 'gacutil', its seems to be part of VS, so i'd need to have VS on the server im wanting to run it on in order to register it there? Also, does 'Your_dll_name.dll' include the path name where the file is currently? Thanks.Heterotrophic
gacutil is standalone utility and can be safely copied to the server - it doesn't require full installation of VS to work. Regarding name - in general case, yes, full path to dll should be writtenEames

© 2022 - 2024 — McMap. All rights reserved.