daveamour
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\Cla ss1.cs(4): Duplicate 'AssemblyVersion' attribute
and
C:\Documents and Settings\daveamour\My Documents\Visual Studio Projects\ClassLibrary1\Cla ss1.cs(5): Duplicate 'AssemblyKeyFile' attribute
Here is my class code:
using System;
using System.Reflection;
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyKeyFile("dotNETCom ponent.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
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\Cla
and
C:\Documents and Settings\daveamour\My Documents\Visual Studio Projects\ClassLibrary1\Cla
Here is my class code:
using System;
using System.Reflection;
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyKeyFile("dotNETCom
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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();
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();
ASKER
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
Many thanks
Dave
ASKER
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