Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Issues creating C Sharp Dll in .Net

Posted on 2011-10-24
5
Medium Priority
?
388 Views
Last Modified: 2013-12-16
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
0
Comment
Question by:mcs26
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:fritzfrancis
ID: 37019788
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

0
 

Author Comment

by:mcs26
ID: 37020767
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
0
 
LVL 4

Accepted Solution

by:
fritzfrancis earned 2000 total points
ID: 37021824
Yes, you have to give your assembly a strong name. On the property pages of your project, go to the "Signing" tab and click on the "Sign this assembly" check box and enter a name for the key file.
10-24-2011-8-38-59-PM.png
0
 

Author Comment

by:mcs26
ID: 37023524
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
0
 
LVL 4

Expert Comment

by:fritzfrancis
ID: 37026665
Try following the steps in this article, http://support.microsoft.com/kb/817248. Maybe it would make a difference.
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

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.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

580 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