Ysgrifennodd dimagofman@googlemail.com:
Comments in the text. My examples are in C#, because that's what I use.
VB gives me the creeps:
> Peter,
>
[quoted text clipped - 6 lines]
> into the GAC (maybe this is wrong? maybe I should use the command line
> util?)
If you're using .NET 2.0, you're *possibly* putting them in the wrong
place. What version of .NET are you using?
I always use the tools provided in Visual Studio to put stuff in the GAC
- either gacutil or the configuration tool.
http://visualbasic.about.com/od/usingvbnet/a/asmnet01_3.htm
The following url (http://www.codeproject.com/dotnet/demystifygac.asp)
says this about configuring the gac:
<quote>
In order for the GAC to be useful, we need to be able to interact with
it. I am aware of the following five interfaces available for such
interaction.
1. The Windows Installer 2.0
2. The command line tool GACUtil.exe
3. The Windows Shell namespace extension implemented in SHFusion.dll
4. The .NET Framework Configuration Administrative tool
</quote>
Also bear in mind what I said about recompilation. It's not enough that
the version number, culture etc etc match. The hash of the code has to
match. So any recompile means you have to put the new assembly in the
GAC and renew all your references in order to import the correct dll to
compile against. Forgetting to renew references is a favourite gotcha.
> To take a specific example
> The structure of code in an assembly is like so:
[quoted text clipped - 14 lines]
> you reference the namespaces/objects in your code-behind? On my page
> where I need to use one assembly I have:
Add references in the code-behind. Just as I would in any other .NET code.
> <%@ Page Language="VB" %>
> <%@ Import Namespace="CFA.DB" %>
[quoted text clipped - 8 lines]
> <add assembly="CFA.DB, Version=1.1.0.0, Culture=neutral,
> PublicKeyToken=xxx"/>
It would work if you were coding in-line. For example it works for
Global.asax. But if you're using code-behind your Page declaration
should look something like this (for a default.aspx page):
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="default.aspx.cs"
Inherits="user" %>
If you use code behind, you can add references as you would into any
.NET project.
Global.asax, for example, is always in-line in .NET 2.0, so I have
something like this for inline coding:
<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Security.Principal" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
etc, etc
</script>
Are you using code behind or inline code? I suspect the latter, from
what you've said. Is there some reason you're not using code behind?
> I must admit I find this process very confusing, so much for "the end
> to dll hell", COM was much easier.
Now I know you're joking!
:D
Peter