How to register a .NET COM DLL for use on another computer

I have a .NET DLL written in VB and can createobject fine on the local machine

When I try this from a client machine I get "activex component cant create object"

    Set obj = CreateObject("MyApp5.Response", "ServerName")
    MsgBox obj.SomeMethod()

How should .NET DLLs be registered so that a remote "createobject" will work ?
LVL 8
plqAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

skytrueCommented:
You have to use regasm to register the dll on the client machine. And you can use gacutil to install it into global assembly cache.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
plqAuthor Commented:
OK I've done the following:

- Add a class to the DLL called MtsClass
    which Inherits System.EnterpriseServices.ServicedComponent
- Build on the server
- Run regsvcs on the server
- Copy the dll to the local e: drive on the client
- regasm the e: drive dll (types registered successfully) on the client computer
- rerun the vb - activex component cant create object

any ideas ? thanks

0
plqAuthor Commented:
(i did drop the e: drive dll into the GAC too)
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

skytrueCommented:
Did you use gacutil -i e: dll to add it to global assembly cache?
0
skytrueCommented:
Sorry, didn't see your last comment.

Does your DLL require other DLLs which exist on your server but not client machines?
0
skytrueCommented:
And you may want to try this out:

1. Add an Installer class to your assembly that needs to be registered.

a. In VS, right click on the Project name and select Add; then Add New
Item.
b. In the Add New Item dialog, select Installer class.
c. Select Open.

2. Edit the Code for Installer1.vb in the code editor.

a. Add the following statements to the Imports section:

Imports System.Runtime.InteropServices
Imports System.Reflection

b. Add the following code beneath the Component Designer generated code:

Public Overrides Sub Install(ByVal savedState As
System.Collections.IDictionary)

End Sub

Public Overrides Sub Commit(ByVal savedState As
System.Collections.IDictionary)

Dim MyAssembly As [Assembly]

MyAssembly = MyAssembly.GetCallingAssembly()

Dim reg As System.Runtime.InteropServices.RegistrationServices = _

New System.Runtime.InteropServices.RegistrationServices

reg.RegisterAssembly(MyAssembly, AssemblyRegistrationFlags.SetCodeBase)

End Sub

Public Overrides Sub Rollback(ByVal savedState As
System.Collections.IDictionary)

End Sub

Public Overrides Sub Uninstall(ByVal savedState As
System.Collections.IDictionary)

Dim MyAssembly As [Assembly]

MyAssembly = MyAssembly.GetCallingAssembly()

Dim reg As System.Runtime.InteropServices.RegistrationServices = New
System.Runtime.InteropServices.RegistrationServices

reg.UnregisterAssembly(MyAssembly)

End Sub

3. In your Setup project, add the Primary output of the above project

4. Open the Custom Actions Editor

5. Add the Primary Output of the above project to all nodes in the Custom
Actions Editor.

a. Right click on the Custom Actions node and select Add Custom Action.
b. Browse to the location Primary output of the above project, select it
and then
click OK.

6. Build the setup and run it on the target machine.
0
plqAuthor Commented:
Phew thats scary. The DLL runs fine on the client when I install the app locally, its only when doing a createobject with the dll on another machine that i get the problem - activex component cant create object.

Given that, do you think all the above is necessary ? I am a bit worried about adding "installer code" to the main dll because its very big and already in production.
0
plqAuthor Commented:
Hold on...
0
plqAuthor Commented:
I just got it working.

Don't quite know what made the difference but here's what I did

- Unregister everything I could think of
- Reboot both machines
- Moved the ServicedComponent inheritance from its own class to the main class that is created in COM
- Recompile on the dev machine (=server)
- Add to GAC on the server
- Add to Component Services on the server
- Changed the configured identity to be the administrator account on the server
- Exported the components services app to an MSI file
- Installed that MSI on the client
- Set the configured identity on the client to be the administrator account on the client

That was it ! I think there were a few things in there that could've been wrong.

thanks for helping anyway
0
plqAuthor Commented:
Ugh its a big mess to write an installer that does all this. Cant believe MS made things so difficult

So what I'm going to do instead is write a simple VB6 ActiveX proxy DLL which sits on the server and replaces the .NET DLL by handling all the same properties and methods. That way the .NET DLL can remain untouched, and the VB6 ActiveX DLL is simple to write and simple to deploy.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.