Assembly works when placed in \Bin folder, but not GAC


A

Abe Simpson

Hi all,

I wrote an object in C# to be used from ASP.NET applications. The namespace
the object resides in is "AcmeSoft.MyObj". The assembly name is
AcmeSoft.MyObj.dll.

Now, then I put the assembly in the \Bin directory of my application and
invoke it with

<%@ Import Namespace="AcmeSoft.MyObj" %>

it works just fine.

I want to be able to put the assembly in the GAC too. I did make it strongly
named (key pair and all.) I could not for some reason drag/drop the DLL to
the GAC but I could put it there via GACUTIL /i command. However, now the
Import statement generates the error

CS0246: The type or namespace name 'AcmeSoft' could not be found (are you
missing a using directive or an assembly reference?) But AcmeSoft.MyObj is
clearly in the GAC!

Can someone shed some light?

Thanks.

-- Abe
 
Ad

Advertisements

S

Scott M.

There are 3 steps in order to make a GAC assembly and it looks like you've
skipped step two.

First, you strong name the assembly.
Second, you register that strong name in the AssemblyInfo.vb/.cs file with
the assembly:assemblykeyfile attribute.
Third, you register the assembly into the GAC using GACUTIL.

-Scott
 
A

Abe Simpson

Thanks for replying, Scott.

I am not using the [assembly:assemblykeyfile] line because I was getting a
warning message when I tried it. Instead, I used the Signing tab in the
project properties window to specify my key pair file.

-- Abe
 
Ad

Advertisements

S

Scott M.

I know Abe, but I've found that you should put the assembly:assemblykeyfile
attribute in the assemblyinfo.cs file for it to work properly.

-Scott

Abe Simpson said:
Thanks for replying, Scott.

I am not using the [assembly:assemblykeyfile] line because I was getting a
warning message when I tried it. Instead, I used the Signing tab in the
project properties window to specify my key pair file.

-- Abe


Scott M. said:
There are 3 steps in order to make a GAC assembly and it looks like
you've skipped step two.

First, you strong name the assembly.
Second, you register that strong name in the AssemblyInfo.vb/.cs file
with the assembly:assemblykeyfile attribute.
Third, you register the assembly into the GAC using GACUTIL.

-Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top