[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2004-11-18
10
Medium Priority
?
301 Views
Last Modified: 2008-02-01
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 ?
0
Comment
Question by:plq
  • 6
  • 4
10 Comments
 
LVL 1

Accepted Solution

by:
skytrue earned 2000 total points
ID: 12615093
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
 
LVL 8

Author Comment

by:plq
ID: 12615188
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
 
LVL 8

Author Comment

by:plq
ID: 12615205
(i did drop the e: drive dll into the GAC too)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Expert Comment

by:skytrue
ID: 12615263
Did you use gacutil -i e: dll to add it to global assembly cache?
0
 
LVL 1

Expert Comment

by:skytrue
ID: 12615276
Sorry, didn't see your last comment.

Does your DLL require other DLLs which exist on your server but not client machines?
0
 
LVL 1

Expert Comment

by:skytrue
ID: 12615340
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
 
LVL 8

Author Comment

by:plq
ID: 12615606
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
 
LVL 8

Author Comment

by:plq
ID: 12616067
Hold on...
0
 
LVL 8

Author Comment

by:plq
ID: 12616149
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
 
LVL 8

Author Comment

by:plq
ID: 12623184
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question