I am sorry if this is stupid questions, but i've spend two days on this, and can't get it to work. Here's what I did:
- Create a new class library project
- Added a simple method
sayHi()
that returns a string - In the project properties checked "sign the assembly" and used a strong name key file
- Compiled the application and copied the DLL to c:\windows\assemblies (and i also tried using the gacutil tool with similar results)
- Added the following to machine.config
<compilation><assemblies><add assembly="gacTestClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31418215e131202e" />
. This works just fine, because if i misspell the assembly name, any .net app will fail and complain about that line. - Using the assembly cache viewer in the .NET framework configuration tool i can see the assembly in the cache.
- Now, when i try to use that, my app fails when i do either
using gacTestClass
orgacTestClass.gacTest.sayHi()
. I get an error saying that the type or namespace could not be found.
Any help is appreciated.
EDIT:
Ok, i followed a suggestion and I will try to make this work with web.config, rather than machine.config.
I added the following to my web.config <compilation><assemblies><add assembly="gacTestClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31418215e131202e" />
and made sure that it works by misspelling the name, and watching the app fail.
Now, when I try to add using gacTestClass
to the top of my .cs file, i get an error saying that the type or namespace could not be found.
Just in case, here's the code the for the gacTestClass
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
[assmbly:AssemblyKeyFile("sayHi.snk")]
namespace gacTestClass {
public class gacTest {
public string sayHi() {
return "Hello there!";
}
}
}