Solved

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

Posted on 2014-03-07
1
648 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

688 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