How do I make a DLL that all web sites can use (like an old COM object)?

A

Alan Silver

Hello,

In Classic ASP, you could whip up a DLL in VC++, VB, etc and register it
on the server somewhere (anywhere actually). Once registered, any ASP in
any web site could use it by doing ...

Set objMyObj = Server.CreateObject("MyDLL.MyClass")

How do I do a similar thing in ASP.NET?

I have an e-commerce package that is currently written in Classic ASP
and VB6. I am looking at rewriting it in ASP.NET. One of the strong
features of the current package is that all of the relevant code is
housed in a single DLL which all sites use. If I fix any bugs or make
improvements, I only need to update the one DLL and all sites see the
benefit immediately.

As far as I can see, ASP.NET only looks in the /bin directory for DLLs.
Does that mean I have to have a copy of the DLL in the /bin directory of
every web site that uses the package? That sounds very inefficient. I'm
sure there's a much better way to do this.

TIA for any help.
 
B

bill

I believe the GAC is supported and well documented.
http://support.microsoft.com/default.aspx?scid=kb;en-us;315682

-Bill

Alan Silver said:
You can use the Global Assembly Cache as a global repository of Assemblies.

http://www.codeproject.com/dotnet/demystifygac.asp

Thanks for the link, looks very interesting. I haven't read it fully
yet, but skimming the first few paragraphs gives the impression that
this is unsupported cloak and dagger stuff. Is that right? I would like
to stick to documented and supported practices if possible.

Any comments?
 
B

bruce barker

you have a couple options

1) register in gac. must sign code, and do an actual install on the server.
2) create a com wrapper and host in com+. note really recommened as there
are performance costs
3) copy the dll. this is the peferred method as it gets rid of dll hell. you
can change the dll, and no site is effected until its rebuilt and tested
with the new dll. the only cost is disk space on the server. adding a
reference to the dll in vs, will cause vs to do the copy for you, so you
only need to store the master copy in one place.

-- bruce (sqlwork.com)


| Hello,
|
| In Classic ASP, you could whip up a DLL in VC++, VB, etc and register it
| on the server somewhere (anywhere actually). Once registered, any ASP in
| any web site could use it by doing ...
|
| Set objMyObj = Server.CreateObject("MyDLL.MyClass")
|
| How do I do a similar thing in ASP.NET?
|
| I have an e-commerce package that is currently written in Classic ASP
| and VB6. I am looking at rewriting it in ASP.NET. One of the strong
| features of the current package is that all of the relevant code is
| housed in a single DLL which all sites use. If I fix any bugs or make
| improvements, I only need to update the one DLL and all sites see the
| benefit immediately.
|
| As far as I can see, ASP.NET only looks in the /bin directory for DLLs.
| Does that mean I have to have a copy of the DLL in the /bin directory of
| every web site that uses the package? That sounds very inefficient. I'm
| sure there's a much better way to do this.
|
| TIA for any help.
|
| --
| Alan Silver
| (anything added below this line is nothing to do with me)
 
J

Juan T. Llibre

re:
skimming the first few paragraphs gives the impression that this is
unsupported cloak and dagger stuff. Is that right?

No, it's not.

Placing an assembly in the GAC will make
it available to *all* applications on a server.

Nothing "cloak and dagger" about that.
It simply works.

re:
I would like to stick to documented and supported practices if possible.

Placing assemblies in the GAC *is*
a documented and supported practice.






Alan Silver said:
You can use the Global Assembly Cache as a global repository of
Assemblies.

http://www.codeproject.com/dotnet/demystifygac.asp

Thanks for the link, looks very interesting. I haven't read it fully yet,
but skimming the first few paragraphs gives the impression that this is
unsupported cloak and dagger stuff. Is that right? I would like to stick
to documented and supported practices if possible.

Any comments?
 
K

Kevin Spencer

Hi Alan,

You can whip up a DLL in Visual Studio.Net by creating a Class Library
project. Once you've created it, you have 2 basic choices:

1.Put a copy in the bin folder of any app that needs it.
2. Register it in the Global Assembly Cache. The GAC works a ot like the COM
registry.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
A

Alan Silver

re:
No, it's not.

Good ;-)
Placing an assembly in the GAC will make
it available to *all* applications on a server.

Nothing "cloak and dagger" about that.
It simply works.

Fine, it was just an impression I got from a quick skim through the
start of that article. I'm glad it was a wrong impression!!
re:

Placing assemblies in the GAC *is*
a documented and supported practice.

That's fine then. Thanks for the reassurance.
 
A

Alan Silver

Hi Alan,
You can whip up a DLL in Visual Studio.Net by creating a Class Library
project. Once you've created it, you have 2 basic choices:

1.Put a copy in the bin folder of any app that needs it.
2. Register it in the Global Assembly Cache. The GAC works a ot like the COM
registry.

Thanks, I spent some time last night reading up on the GAC. It looks
like what I want.

When you update a DLL in the GAC, can you just copy a new version over
the old one, like you can with DLLs in the bin directory, or is there
anything more to do, given that they have to be registered with the GAC?

Ta ra
 
K

Kevin Spencer

When you update a DLL in the GAC, can you just copy a new version over the
old one, like you can with DLLs in the bin directory, or is there anything
more to do, given that they have to be registered with the GAC?

That's a good question, Alan. The answer is a little complicated. Part of
the answer depends on the version. The GAC can support multiple versionsof
the same assembly, for use by different apps that need different versions.
If the version doesn't match, a second version will be added. If the version
does match, you will need to reboot the machine before the change will take
place. The GAC caches assemblies.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
A

Alan Silver

When you update a DLL in the GAC, can you just copy a new version over the
That's a good question, Alan. The answer is a little complicated. Part of
the answer depends on the version. The GAC can support multiple versionsof
the same assembly, for use by different apps that need different versions.
If the version doesn't match, a second version will be added. If the version
does match, you will need to reboot the machine before the change will take
place. The GAC caches assemblies.

Bleah ;-(

With COM, I could update a DLL and, as long as the public signatures
didn't change, I could just stop the MTS package (or COM+ application)
and copy the DLL over the old one. I could happily increase the version
number and not worry about it.

With the GAC it sounds like life is going to be a whole lot more
complex. I don't want multiple versions, the whole point of my question
was that I have a situation where I specifically want ALL applications
(ie all e-commerce sites on the server) to use the very same DLL.

Isn't there a better way around this? I can't reboot the server every
time I make a change.

Thanks
 

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

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top