?
Solved

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

Posted on 2014-03-07
1
Medium Priority
?
656 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

770 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