Somewhere besides "bin" directory to put managed dlls?

J

Jim Bancroft

New to ASP.Net over here, so apologies if this is a basic question-- I'm
using VB .Net to build a managed dll, which I then use in some aspx files.

Works fine, except every time I recompile I have to copy the dll into the
"bin" directory off my root web, otherwise ASP.Net won't find it. I've
added my components the GAC (using gacutil), but that didn't seem to make a
difference-- "bin" or bust, I'm getting.

How can I use my dll without having to copy it to the bin directory every
time I change it? Thanks for the clarifications.
 
M

Marina

The GAC shoudl work just fine. If this isn't working, it is probably because
the version of the DLL in the GAC, is not the same as the version of the DLL
your asp.net classes were compiled with.
 
N

news.microsoft.com

You can right click on the project in the IDE, choose properties>>
configuration settings>> build, and tell .net where to compile your .dll to
 
G

Guest

Are you dynamically loading the assembly? I'm guessing that this is the case
because if your Web Application had a reference to it it would be coppied
automatically.

Please tell us more about how you reference/load the assembly.
 
J

Jim Bancroft

First, thanks for your help. Same goes for the other posters above.

As to your question...you want to know how I load the assembly? Well, my
aspx file reads like this at the top. It's a throwaway page, nothing fancy:

<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace = "ClassLibrary1.TransactionTest001"%>

<script runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
HelloWorld.Text = "Hello World!"
End Sub
</script>

<html>
<head>
<title>ASP.NET Hello World</title>
</head>
<body bgcolor="#FFFFFF">

<p><asp:label id="HelloWorld" runat="server" /></p>
<%
Dim testobject as Test1
testobject = new Test1
testobject .SomeTestMethod()
%>

Just importing my namespace and creating the object using New(). My page
doesn't use any web.config files, nothing besides what you see here.

-Jim
 
G

Guest

If I'm not mistaken (and I may be) the @ Import directive is equivalent to a
"using" directive, it doesn't actually cause the assembly to be referenced.

When I build an assembly that I'm going to install in the GAC I have a post
build step that's something like this:

echo Installing assemblies in the Global Assembly Cache
path=%path%;"C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\"
for %%a in ($(TargetDir)*.dll) do gacutil /i "%%a" /f
echo Windows Registry Editor Version 5.00>$(ProjectName).reg
echo
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\$(ProjectName)]>>$(ProjectName).reg
set td=$(TargetDir)
echo @="%td:\=\\%">>$(ProjectName).reg
regedit /s $(ProjectName).reg

This causes the assembly to appear in the .NET tab of the "Add Reference"
dialog.

If you add a reference to your assembly from your web application, I think
that you'll find that the web application uses the assembly in the GAC. You
wont need a copy of that assembly in the bin directory.

There may be a simpler way but this works for me.
 

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,995
Messages
2,570,228
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top