Finally!!!
I have been able to figure it all out.
After the DLL has been added to the GAC (you will need to create a strongly typed DLL to be able to add your DLL to the Global Assembly Cache GAC), you have to add the DLL manually to the machine.config file that is located under:
%systemroot%\Microsoft.net\Framework\<versionnumber>\config
The lines to be added have to be added in the following structure: (This example adds the WebCounter.dll)
<configuration>
<system.web>
<compilation debug="false" explicit="true" defaultLanguage="vb">
<assemblies>
<add assembly="WebCounter, Version=1.0.1480.30047, Culture=neutral, PublicKeyToken=c434ff78305dda8b" />
</assemblies>
</compilation>
</system.web>
</configuration>
Verson and PublicKeyToken can be retrieved from the GAC that is located under:
%systemroot%\assembly
Locate your DLL that you have added to that store, and right click to check the info in the properties.
BTW, a handy dandy idea is to add the following tool to your MS VS.NET Development IDE:
(select menu "Tools" - "External Tools" - "Add")
Enter the following fields:
Title: "Create Assembly Ke&y File"
Command: "D:\Microsoft\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\sn.exe" (needs to be adjusted to your drive and path for sn.exe)
Arguments: "-k $(TargetDir)$(TargetName).snk"
Initital Directory: "$(TargetDir)"
Check the option: Output window (that will allow you to copy & paste the output file after successful generation into the AssemblyKeyFile directive of your AssemblyInfo.vb file.
From now on you will be able to select that command and the tool will create the key pair file for you that will have to be added to the DLL project's "AssemblyInfo.vb" file in the following line:
<Assembly: AssemblyKeyFile("E:\Development\WebTools\WebCounter\obj\Release\WebCounter.snk")>
Hope that this info will help somebody to save a lot of trouble. I wished that info would be available as a knowledge base article on MSDN.
All the best,
Wolfgang Kaml
Luke,
What I am trying to do since day one is to exactly avoid what you are talking about.
I mean - does Microsoft define "reuse" as a "copy and paste"???
I am reading tons of messages in this same newsgroup that people are having troubles to use the GAC. So do I. I have developed an ASP.NET Service Control called WebCounter.
Doing so, I exactly followed the instructions and example as described in the article
http://msdn.microsoft.com/library/d...n-us/dnaspp/html/aspnet-simulatinginclude.asp
And, there is another article on that:
http://msdn.microsoft.com/library/d...n-us/dnaspp/html/aspnet-simulatinginclude.asp
Furthermore, the later article finishes with the following Conclusion:
Creating a Web server control is very different from creating a Web user control. You will end up writing a lot less code in the UI layer when you employ a server control, as you can take advantage of inheritance. Since you will be creating a DLL, this will also ensure that no one can modify your source code. With a user control, anyone can view and see the source code. Another advantage of a server control over a user control is you only need one copy of the DLL on a single server. This one DLL can service all Web sites. With user controls, you would have to copy the user control from site to site. This makes maintenance of these user controls very difficult. With the server control, you only need to modify the control in one location.
OK, so what the guy apparently is talking about is, is adding the DLL to the GAC. Or is there another way of doing it? If so, I'd like to know that route.
Since he is mentioning, that one DLL one one single server can service all Web sites, I'd like to know, of how that is done.
Cause if I use this code:
<%@ Page Language="vb" AutoEventWireup="false" %>
<%@ Import Namespace="WebCounter" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Counter Test Page</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="
http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body>
<P><FONT face="Verdana" size="2">The counter value is:
<%
Dim objWebCounter as WebCounter
objWebCounter = new WebCounter
Response.Write(objWebCounter.CounterValue)
%>
some more text ...</FONT></P>
</body>
</HTML>
I get the error message:
Server Error in '/_counter' Application.
--------------------------------------------------------------------------------
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30002: Type 'WebCounter' is not defined.
Line 13: <P><FONT face="Verdana" size="2">The counter value is:
Line 14: <%
Line 15: Dim objWebCounter as WebCounter
Line 16: objWebCounter = new WebCounter
Line 17: Response.Write(objWebCounter.CounterValue)
Source File: E:\Inetpub\wwwroot\_counter\CounterPage.aspx Line: 15
Show Detailed Compiler Output:
d:\windows\system32\inetsrv> "d:\windows\microsoft.net\framework\v1.1.4322\vbc.exe" /t:library /utf8output /R:"d:\windows\assembly\gac\system.enterpriseservices\1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseservices.dll" /R:"d:\windows\microsoft.net\framework\v1.1.4322\temporary asp.net files\_counter\7a85ec77\15f41ae1\assembly\dl2\9da2aca3\00a42807_5bdec301\counter.dll" /R:"d:\windows\assembly\gac\system.web.mobile\1.0.5000.0__b03f5f7f11d50a3a\system.web.mobile.dll" /R:"d:\windows\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll" /R:"d:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll" /R:"d:\windows\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll" /R:"d:\windows\assembly\gac\system.web.services\1.0.5000.0__b03f5f7f11d50a3a\system.web.services.dll" /R:"d:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll" /R:"d:\windows\assembly\gac\system.web\1.0.5000.0__b03f5f7f11d50a3a\system.web.dll" /out:"D:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\_counter\7a85ec77\15f41ae1\o92unl_i.dll" /D
EBUG=1 /debug+ /win32resource:"D:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\_counter\7a85ec77\15f41ae1\o92unl_i.res" "D:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\_counter\7a85ec77\15f41ae1\o92unl_i.0.vb"
Microsoft (R) Visual Basic .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322.573
Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.
D:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\_counter\7a85ec77\15f41ae1\o92unl_i.0.vb(28) : error BC30466: Namespace or type 'WebCounter' for the Imports 'WebCounter' cannot be found.
Imports WebCounter
~~~~~~~~~~
E:\Inetpub\wwwroot\_counter\CounterPage.aspx(15) : error BC30002: Type 'WebCounter' is not defined.
Dim objWebCounter as WebCounter
Please, NO more references to other articles. Believe me, I have been reading them all. And again: I am not talking about a user control. That stuff needs to be copied and pasted to every single web site I want to use it at. I can't believe that Microsoft had the idea of "Copy & Paste" when designing the .Net Framework and ASP.NET.
Please tell, what I am missing that my aspx file does not find the WebCounter control in the GAC.
Thanks,
Wolfgang