Link to home
Start Free TrialLog in
Avatar of daveamour
daveamourFlag for United Kingdom of Great Britain and Northern Ireland

asked on

GAC Issues

I have some issues with adding a .net class to the GAC

I follows this article:

http://www.aspzone.com/articles/john/GAC/

And it seemed to work fine.  To add the DLL to the GAC though I just dragged and dropped it in explorer.

My first problem is that my code compiles when I do so at the command line but from Visual Studio.net it gives the following error:

C:\Documents and Settings\daveamour\My Documents\Visual Studio Projects\ClassLibrary1\Class1.cs(4): Duplicate 'AssemblyVersion' attribute

and

C:\Documents and Settings\daveamour\My Documents\Visual Studio Projects\ClassLibrary1\Class1.cs(5): Duplicate 'AssemblyKeyFile' attribute

Here is my class code:

using System;
using System.Reflection;

[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyKeyFile("dotNETComponent.snk")]

public class Maths
{
     public Maths()
     {

     }

     public int AddNumbers (int a, int b)
     {
               return a + b;
     }
}

My other issue is once my class is in the GAC, how do I actually use it in my code?

Cheers

Dave
ASKER CERTIFIED SOLUTION
Avatar of naveenkohli
naveenkohli

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 daveamour

ASKER

Ok thanks, thats a great help.

I must be being thick though as I don't know hwo to use this Class.

My Class is Maths as you can see from the above code but my project was saved as ClassLibrary1 in the GAC.

How do I use this - I've tried using ClassLibray1 but that doesnt work.  Can you give me an idiots guide please?

Thanks

Dave
Avatar of naveenkohli
naveenkohli

put you class under a namespace.

namespace davLibs
{
 public class Maths
 {
...
...
 }
}

Compile it. And then inthe project where you want to use it, add reference to this library and at the top of file import your namespace (although not ncessary).

using davLib;

Maths ob = new Maths();
ob.foo();

Ok thanks, I still have some issues but I've managed to get something working.   I'll go and do some more work then maybe come back with a fresh question.

Many thanks

Dave