473,385 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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
11 3092
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: David Elliott | last post by:
I have created an application that will dynamically load other DLLs (plugins). The new plugin is a winform with an embedded IE Browser. I am wanting to have the form to run in its own thread....
0
by: Lauchlan M | last post by:
<< Compiler Error Message: CS1595: 'myWebInterface.X.Y.AddEditUsers' is defined in multiple places; using definition from 'e:\WINNT\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET...
0
by: Lauchlan M | last post by:
<< Compiler Error Message: CS1595: 'myWebInterface.X.Y.AddEditUsers' is defined in multiple places; using definition from 'e:\WINNT\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET...
4
by: Don Wash | last post by:
Hi All! I'm getting the following Error: No DLLs has been compiled yet and nothing in the \bin directory. So it is not the versioning problem or anything like that. And here are the...
5
by: Jay A. Moritz | last post by:
Error: The dependency '<my dll>' in project '<my project>' cannot be copied to the run directory because it would conflict with dependency '<my dll>'. I am getting a dependency error building...
3
by: noreponse1 | last post by:
Hello, I have a solution that contains two projects. I have 2 dlls that these projects use. Here's how it's set up: Solution -ProjectA --References ---DLLA -ProjectB
1
by: sharmadeep1980 | last post by:
Hi All, I am facing a very unique problem while compling my project in "Release" build. The project is building in DEBUG mode but giving linking error on Release build. Here is the error:...
5
by: Rainer Queck | last post by:
Hello NG, Is it possible to share the settings of an application with a class libreary? In my case I have a application and a set of different reports (home made) put into a class library. The...
5
by: tshad | last post by:
I have the following class in my VS 2008 project that has a namespace of MyFunctions. ********************************* Imports System Imports System.Text.RegularExpressions Namespace...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.