By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,131 Members | 1,437 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,131 IT Pros & Developers. It's quick & easy.

setting up general app path for DLLs and avoiding Could not load type '<project>.<class>' error

P: n/a
I am not sure if this is more of an expert question, but I am sure that they
are out there.

I'd like to setup a general application or bin directory on my Win2003.Net
Server that will hold some useful utils that more pages on that server can
use.
As an example, I have created a Page Counter class that opens an Access .mdb
file, counts the current entries for that page, and adds a new entry with
some information regarding the current request. That counter works great on
that same page it has been developed for and as long as the bin directory
with the DLL sits right beneath that path.

Now, what I'd like to do is to setup a general bin or app direcotry on my
Win2003.Net Server where I can move that counter.dll to and to which all the
pages that want to use that counter can refer to. I assume, that there would
be at least 2 steps necessary to accomplish that.
1) setting up an app path on the Win2003.Net Server and somehow 'publishing'
that app path for all the pages
2) modifying the first line of the .aspx file to refer to that directory or
load it from somewhere else then the default /bin.

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="CounterPage.aspx.vb" Inherits="Counter.CounterPage"%>
How to modify that line to refer to some other directory then the local/bin?

3) Are there modifications to Web.config necessary, and does it have to be
placed in every single page's path?
I'd really appreciate your help and describing the steps necessary to
accomplish that.

Thanks,
Wolfgang
Nov 18 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
Hi,

what about using the GAC. you can register your Utility DLLs there and
call them from each and every apllication on the server.
Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2

P: n/a
HI Wolfgang,

Thank you for using MSDN Newsgroup. I am Luke and I am review this issue
currently. As I understand, you want to create a DLL which can be used as
codebehind by multiple ASP.NET application. However, in ASP.NET
application, the DLL files have to be placed in its individual BIN folder.
we can't set it to another folder.

Regarding the problem, I think there should be two work around:

1. As Natty suggest, create a library assembly with strong name and put it
into GAC. Then you can access it from any of ASP.NET appliaction. For .NET
GAC, you may refer to:

http://support.microsoft.com/default...;EN-US;Q315682
How To: Install an Assembly in the Global Assembly Cache in Visual Basic
NET

2. Create a ASP.NET Web Usercontrol for the page counter function and use
this control in every page you need. In this way, Web Usercontrol's dll
file will be added in to the local BIN folder.

Hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #3

P: n/a
Luke,

Thank you for your help. I was able to create the cryptographic key pair
with the SN tool, add that to the AssemblyInfo.vb file and generate a DLL
that I added to the GAC.
However, I am still getting the error message:
Parse Error Message: Could not load type 'Counter.CounterPage'

The project in VB.NET is called "Counter", and the class I created is
"CounterPage".

I changed the top line in my aspx file to be:
<%@ Page Language="vb" AutoEventWireup="false"
Inherits="Counter.CounterPage"%>

Why would I still get the Parse Error Message?

Thank you,
Wolfgang
"MSFT" <lu******@online.microsoft.com> wrote in message
news:hL*************@cpmsftngxa07.phx.gbl...
HI Wolfgang,

Thank you for using MSDN Newsgroup. I am Luke and I am review this issue
currently. As I understand, you want to create a DLL which can be used as
codebehind by multiple ASP.NET application. However, in ASP.NET
application, the DLL files have to be placed in its individual BIN folder.
we can't set it to another folder.

Regarding the problem, I think there should be two work around:

1. As Natty suggest, create a library assembly with strong name and put it
into GAC. Then you can access it from any of ASP.NET appliaction. For .NET
GAC, you may refer to:

http://support.microsoft.com/default...;EN-US;Q315682
How To: Install an Assembly in the Global Assembly Cache in Visual Basic
NET

2. Create a ASP.NET Web Usercontrol for the page counter function and use
this control in every page you need. In this way, Web Usercontrol's dll
file will be added in to the local BIN folder.

Hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #4

P: n/a
Hi Wolfgang,

We can't set the "Inherits" to a type in GAC. To use it, create a new
common asp.net project, and add a reference to the assembly (set the
reference's Copy Local to false so that it will use the copy in GAC). and
then create a object from the type. For example:

Dim CPgae as new Counter.CounterPage

CPage.SomeMethod.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #5

P: n/a
Thanks for your response Luke.

I'm not sure if I understand the basic concept anymore from reading your
info. Maybe you need to help me clarify a few things first.

When we talk about the production Win2003 server machine, where no VS.Net is
installed, just the .Net Framework 1.1, I thought the GAC is being used to
avoid making multiple copies of one and the same Assembly that might be
reused in different virtual web directories/web pages.
My thinking is, that without the GAC, I have to make a copy of the same
Assembly for every sub page that I want to use it on, e.g.
/page1/bin/myassembly, /page2/bin/myassembly etc
In order to avoid that redundancy and increase maintainability drastically I
thought I could use the GAC, where I will have one app path somewhere and
register the DLLs in the GAC. The web page header then would only have to
refer to that assembly and be ready for use.
Am I correct with that thinking?

If yes, now that I have added my Counter.dll to the GAC, how to I tell the
web page to search in the GAC? It seems to me that the GAC is not being
searched at all because if I delete the /bin directory from my page, I
immediately get the error messages, that it can't find the assembly in the
C:\WINNT\Microsoft.NET\Framework\v1.1.4322\Tempora ry ASP.NET Files folder,
nor in the /page1/bin folder. Why is it not searching the /myassemblies
folder that I have copied the DLL to and that has been registered in the
GAC?
Thank you for all your help! I hope I'm not missing something real basic
here, since I am an absolute newbie.
Wolfgang
"MSFT" <lu******@online.microsoft.com> wrote in message
news:$n****************@cpmsftngxa07.phx.gbl...
Hi Wolfgang,

We can't set the "Inherits" to a type in GAC. To use it, create a new
common asp.net project, and add a reference to the assembly (set the
reference's Copy Local to false so that it will use the copy in GAC). and
then create a object from the type. For example:

Dim CPgae as new Counter.CounterPage

CPage.SomeMethod.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #6

P: n/a
Hi Wolfgang,

I think your understanding on GAC and ASP.NET is incorrect here. Assemblies
in GAC are shared for all applications on currect machine (windows
appliaction, asp.net application, console application...) To use Assembly
in GAC, we need to add a reference to it, not like:

<%@ Page Language="vb" AutoEventWireup="false"
Inherits="Counter.CounterPage"%>

ASP.NET use this way to find assembly in its BIN folder. It can't find
assembly in other place, including GAC.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #7

P: n/a
Luke,

And how would that reference look like?

Because the reference directive needs a file as far as I have seen on MSDN:
<%@ Reference Control="MyControl.ascx" %>

Thanks,
Wolfgang
"MSFT" <lu******@online.microsoft.com> wrote in message
news:dY**************@cpmsftngxa07.phx.gbl...
Hi Wolfgang,

I think your understanding on GAC and ASP.NET is incorrect here. Assemblies in GAC are shared for all applications on currect machine (windows
appliaction, asp.net application, console application...) To use Assembly
in GAC, we need to add a reference to it, not like:

<%@ Page Language="vb" AutoEventWireup="false"
Inherits="Counter.CounterPage"%>

ASP.NET use this way to find assembly in its BIN folder. It can't find
assembly in other place, including GAC.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 18 '05 #8

P: n/a
Hi Wolfgang,

Using @ Reference allows you to dynamically compile a user control and add
it to the ControlCollection object. The .ascx file should be in the same
application. Normally, we use it to load a web control dynamically. for
more information, you can refer to:

http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconinstantiatingusercontrolsprogrammatically.asp

http://msdn.microsoft.com/library/de...us/cpgenref/ht
ml/gngrfreference.asp

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Nov 18 '05 #9

P: n/a
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/de...inginclude.asp

And, there is another article on that:
http://msdn.microsoft.com/library/de...inginclude.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.enterpriseservic es\1.0.5000.0__b03f5f7f11d50a3a\system.enterprises ervices.dll" /R:"d:\windows\microsoft.net\framework\v1.1.4322\te mporary asp.net files\_counter\7a85ec77\15f41ae1\assembly\dl2\9da2 aca3\00a42807_5bdec301\counter.dll" /R:"d:\windows\assembly\gac\system.web.mobile\1.0.5 000.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__b77a 5c561934e089\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:DEBUG=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\Temp orary 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\Tempo rary 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

"MSFT" <lu******@online.microsoft.com> wrote in message news:ti***************@cpmsftngxa07.phx.gbl...
Hi Wolfgang,

Using @ Reference allows you to dynamically compile a user control and add
it to the ControlCollection object. The .ascx file should be in the same
application. Normally, we use it to load a web control dynamically. for
more information, you can refer to:

http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconinstantiatingusercontrolsprogrammatically.asp

http://msdn.microsoft.com/library/de...us/cpgenref/ht
ml/gngrfreference.asp

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #10

P: n/a
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\<versionnumbe r>\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\WebCounte r\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

"Wolfgang Kaml" <ms@no-spam.kaml.com> wrote in message news:uC****************@TK2MSFTNGP10.phx.gbl...
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/de...inginclude.asp

And, there is another article on that:
http://msdn.microsoft.com/library/de...inginclude.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.enterpriseservic es\1.0.5000.0__b03f5f7f11d50a3a\system.enterprises ervices.dll" /R:"d:\windows\microsoft.net\framework\v1.1.4322\te mporary asp.net files\_counter\7a85ec77\15f41ae1\assembly\dl2\9da2 aca3\00a42807_5bdec301\counter.dll" /R:"d:\windows\assembly\gac\system.web.mobile\1.0.5 000.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__b77a 5c561934e089\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:DEBUG=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\Temp orary 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\Tempo rary 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

"MSFT" <lu******@online.microsoft.com> wrote in message news:ti***************@cpmsftngxa07.phx.gbl...
Hi Wolfgang,

Using @ Reference allows you to dynamically compile a user control and add
it to the ControlCollection object. The .ascx file should be in the same
application. Normally, we use it to load a web control dynamically. for
more information, you can refer to:

http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconinstantiatingusercontrolsprogrammatically.asp

http://msdn.microsoft.com/library/de...us/cpgenref/ht
ml/gngrfreference.asp

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #11

P: n/a
Your external tools suggestion is an interesting one, but I would
think that using the same key for all outputs from a development team
would be preferable than a unique signature key per assembly.

What is your rationale for having a new key per assembly?
-Kevin Buchan
ke**********@REMOVETHISTOEMAILtroutmansanders.com

On Wed, 21 Jan 2004 11:43:47 -0800, "Wolfgang Kaml"
<ms@no-spam.kaml.com> wrote:
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\<versionnumb er>\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\WebCounte r\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

"Wolfgang Kaml" <ms@no-spam.kaml.com> wrote in message news:uC****************@TK2MSFTNGP10.phx.gbl...
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/de...inginclude.asp

And, there is another article on that:
http://msdn.microsoft.com/library/de...inginclude.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.enterpriseservic es\1.0.5000.0__b03f5f7f11d50a3a\system.enterprises ervices.dll" /R:"d:\windows\microsoft.net\framework\v1.1.4322\te mporary asp.net files\_counter\7a85ec77\15f41ae1\assembly\dl2\9da2 aca3\00a42807_5bdec301\counter.dll" /R:"d:\windows\assembly\gac\system.web.mobile\1.0.5 000.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__b77a 5c561934e089\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:DEBUG=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\Temp orary 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\Tempo rary 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

"MSFT" <lu******@online.microsoft.com> wrote in message news:ti***************@cpmsftngxa07.phx.gbl...
> Hi Wolfgang,
>
> Using @ Reference allows you to dynamically compile a user control and add
> it to the ControlCollection object. The .ascx file should be in the same
> application. Normally, we use it to load a web control dynamically. for
> more information, you can refer to:
>
> http://msdn.microsoft.com/library/de...us/cpguide/htm
> l/cpconinstantiatingusercontrolsprogrammatically.asp
>
> http://msdn.microsoft.com/library/de...us/cpgenref/ht
> ml/gngrfreference.asp
>
> Luke
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>


Nov 18 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Browse more ASP.NET Questions on Bytes