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

x
?
Solved

deploy com-enable C# ,.Net dll to workstation

Posted on 2014-03-07
1
Medium Priority
?
674 Views
Last Modified: 2014-03-07
I am trying to write a com-enabled .Net DLL in C#, using the .Net 3.5 framework, and on my development machine I can use it in VBA (Excel) like this:

Public Sub try()
    Dim CR As CRPassThroughCOM.Main
    Set CR = New CRPassThroughCOM.Main
   
    Dim tryit As Boolean
    tryit = CR.Report
   
   
   
End Sub

I did notice that when I added the dll to the references, that it pointed to the debug folder, not the release folder.

I then sent the dll (from the release folder) to a personal machine that does not have the development environment.  I registered it with regasm, which on that machine was in the .Net 4.0 framework folder.  I used the /tlb and /codebase switches.

On the personal machine, in Excel VBA I can choose the reference, etc.  However, at tryit = CR.Report, it fails.  Intellisense does not see that method and it won't run.

The DLL looks like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace CRPassThroughCOM
{
    public interface IMain
    {
        bool Report();
    }

    [ComVisible(true)]
    [ClassInterface(ClassInterfaceType.None)]
    public class Main : IMain
    {

        public Main()
        {
        }


        [ComVisible(true)]
        public bool Report()
        {
            try
            {
                MessageBox.Show("We are good, I guess");
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);//TODO: take this out
                return false;
            }
        }
    }
}

Any ideas what I can do to troubleshoot this?  I had to mark the assembly Make Assembly com-Visible to get this method to show up even on the development machine.

Thanks
0
Comment
Question by:g_johnson
1 Comment
 
LVL 4

Accepted Solution

by:
g_johnson earned 0 total points
ID: 39913607
I added in the Guids, and this now works.

    [Guid("62021e3e-5a49-4ccb-b059-3cd1a1421390")]
    public interface IMain
    {
        bool Report();
    }

    [Guid("a5295c27-8054-422b-a6ef-12670a890062")]
    [ComVisible(true)]
    [ClassInterface(ClassInterfaceType.None)]
    public class Main : IMain
    {
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Loops Section Overview
Suggested Courses

864 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