Importing an assembly?

E

Ebbe Kristensen

Hi All

I am trying to get access to an assembly in an ASPX project. I have added
the assembly to GAC using gacutil and added an "%@Import namespace =
"MyNamespace" %" to the .aspx file but this is seemingly not enough since
the using directive in the .aspx.cs file gives the error:

"The type or namespace name "MyNamespace" could not be found (are you
missing a using directive or an assembly reference?)"

Erm, it's the using directive is there. It just fails to compile - and what
on earth is an assembly reference?

More generally, where (and how) can I find the information on how to do
this?

BTW, is your opinion on the Visual Studio help system as low as mine? I find
it virtually impossible to find any information on how to do tasks. Google
is usually much better although in this case it has failed me as well.

Ebbe
 
L

Laurent Bugnion

Hi,

Ebbe said:
Hi All

I am trying to get access to an assembly in an ASPX project. I have added
the assembly to GAC using gacutil and added an "%@Import namespace =
"MyNamespace" %" to the .aspx file but this is seemingly not enough since
the using directive in the .aspx.cs file gives the error:

"The type or namespace name "MyNamespace" could not be found (are you
missing a using directive or an assembly reference?)"

Erm, it's the using directive is there. It just fails to compile - and what
on earth is an assembly reference?

More generally, where (and how) can I find the information on how to do
this?

Placing an assembly in the GAC is not enough to make it available in
your project. You must add an assembly reference in the Solution
explorer: Right click on the "References" folder, choose "Add
reference", and then select your assembly. Since you added it to the
GAC, it should be available from the .NET tab. Other possibilities are
COM components, Projects in the same solution, Browse for a DLL, or
Recently used libraries.

Adding an assembly reference gives you access to the namespaces. If you
have code behind, you want to add a "using" directive (C#) or Import
(VB.NET) to avoid having to retype the full type name everytime you want
to use the class.
BTW, is your opinion on the Visual Studio help system as low as mine? I find
it virtually impossible to find any information on how to do tasks. Google
is usually much better although in this case it has failed me as well.

I find the Help system OK, but it's not enough to learn programming I
think. It won't tell you what an assembly reference is, probably. But I
don't think it's its role either. For tutorials, I like the web and
books better. For references (class libraries), I find MSDN good enough.


Laurent
 
E

Ebbe Kristensen

Laurent said:
Placing an assembly in the GAC is not enough to make it available in
your project. You must add an assembly reference in the Solution
explorer: Right click on the "References" folder, choose "Add
reference", and then select your assembly. Since you added it to the
GAC, it should be available from the .NET tab. Other possibilities are
COM components, Projects in the same solution, Browse for a DLL, or
Recently used libraries.

Thanks. That did it.

Ebbe
 

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

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top