Link to home
Start Free TrialLog in
Avatar of mcs26
mcs26

asked on

Issues creating C Sharp Dll in .Net

Hi,

I am trying to mkae my first dll in .net using C#. I am having a few issues a the moment.

I have attached a word document which outlines the issues I am having. The file contains screen shots and hopefully explains it better than I could do here.

Thanks for any help,
Mark
SimpleCalc.doc
Avatar of fritzfrancis
fritzfrancis
Flag of United States of America image

Are you trying to create a C# DLL to used by Microsoft Office or do you need a C# dll to be used by another .NET application? If you need the latter then you do not need to follow the steps provided by the site you referred to. In other words, you do not need COM Interop. If you need a SimpleCalc.dll just follow these steps.

1. Create a Class Library project in Visual Studio called "SimpleCalc".

2. Rename Class1 to "Calc"

3. Copy this code into the code editor.

4. Lastly, buid the code and you will find a SimpleCalc.dll in your bin/Debug folder of your project folder.

You can use this DLL from any .NET executable or even another .NET dll.
namespace SimpleCalc
{
    public class Calc
    {
        private int _number1;
        private int _number2;

        public void SetNumber1(int number)
        {
           _number1 = number;
        }

        public void SetNumber2(int number)
        {
           _number2 = number;
        }

        public int Add()
        {
            return _number1 + _number2;
        }
    }
}

Open in new window

Avatar of mcs26
mcs26

ASKER

Hi Fritz,

Thanks for the reply. I need the C# DLL to be used by other Microsoft Office applications - Excel & Access. Do you know where I'm going wrong?

Cheers
ASKER CERTIFIED SOLUTION
Avatar of fritzfrancis
fritzfrancis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mcs26

ASKER

I have already ticked the "Sign the assembly" box. I did not give it name for the key file though, is this needed?

I looked in the Registry Editor and found the GUID of my class (see the screen shot) but there are only two files there. (Default) & Version.


Registry.doc
Try following the steps in this article, http://support.microsoft.com/kb/817248. Maybe it would make a difference.