问题
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.
回答1:
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.
回答2:
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
来源:https://stackoverflow.com/questions/20221183/regisering-a-dll-written-in-c-sharp-on-a-windows-server-machine-install-a-c-s