 |
| ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 21st, 2006, 08:54 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Accessing a .NET DLL from Classic ASP
Can anyone tell me if it is possible to access a .NET DLL from Classic ASP?
If so, are there any pitfalls or anything to look out for?
It seems that when moving the DLL from machine to machine, it will not run unless it is compiled locally on each individual machine.
Has this got something to do with the Classic->.NET crossover?
Picco
www.crmpicco.co.uk
|
|

March 27th, 2006, 05:33 AM
|
|
Authorized User
|
|
Join Date: Mar 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Very interesting question Picco,
I will be very interested in checking out the response from an expert.
I can only tell you a few things from my experience with .NET:
- Some security settings prevent .NET code from running if it has not been properly installed in a machine. This can be overcome by strong-naming the assembly and authorizing it to run using the utility ConfigWizards.exe located in directory C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 (or equivalent). For this you need to contact the creators of the .NET DLL
Strong-naming is something that was invented to make sure you know the origin of something that is running... of course, like all these new security fetures, most of the time it prevents the "good" guys from doing their job.
- There are ways to call managed code (.NET) from unmanaged code (here ASP Classic) and vice versa... however, do plan to spend some time making it work!
Cheers,
Joel
|
|

December 7th, 2006, 10:28 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thanks Joel, yeah i though it was a puzzler too! what makes .NET managed and Classic ASP unmanaged?
www.crmpicco.co.uk
www.ie7.com
|
|

December 8th, 2006, 02:53 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Managed code is what we create with .NET, anything that is handled by the Common Language Runtime (CLR). (.NET code is compilied into IL (Intermediate Language) and then executed as needed)
Unmanaged code is what we used to create in Visual Studio 6.0 Borland C++ etc. It is code that is compiled into Native Machine code and runs outside the CLR. (You can determine if a component is managed or unmaged by using the ildasm.exe to try and disassemble it and, if its unmaged, ildasm will say that no CLR Header information was found.)
To answer your question about Interop: (I assume you are using Visual Studio)
After you have created your class library you need to add references to these namespaces:
using System.EnterpriseServices;
using System.Runtime.InteropServices;
Now before your namespace declaration add something like this:
[assembly: ApplicationName("MyClass")]
[assembly: ApplicationActivation(ActivationOption.Server)]
[assembly: ApplicationAccessControl(false,AccessChecksLevel=A ccessChecksLevelOption.ApplicationComponent)]
Where MyClass is whatever you want. As joel said you are going to have to create a Strong Name so you need to do this from a command prompt:
cd C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin
sn âk â[drive]:\[pathtoapplication]\key.snkâ
Now, open the file AssemblyInfo.cs in your class library and find this reference:
[assembly: AssemblyKeyFile("")]
and replace it with this:
[assembly: AssemblyKeyFile(@"key.snk)]
Build your library and this creates a DLL; place the dll in the /bin directory of your web application and register it for COM Interop by going to a command prompt and typing this:
cd âC:\WINDOWS\Microsoft.NET\Framework\v1.1.4322â
regasm "[drive]:\[application]\bin\[name].dll" /tlb /codebase
This will create the tlb file in your bin directory so now all you have to do is go to your asp page and do this:
Dim Obj
Set Obj = Server.CreateObject("[NameSpace].[Class]")
[work with object methods, properties, etc]
Hope this helps!
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
|

December 12th, 2006, 08:39 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
excellent response to my question there dparsons - you clearly know your .NET and ASP! i was under the impression that VB was compiled in a similar way to .NET, but obviously not. :-) Have you got an example of what you mean by "Native Machine Code"?
Cheers
www.crmpicco.co.uk
www.ie7.com
|
|

December 12th, 2006, 09:36 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Don't misunderstand me, VB 6 code IS compiled it just runs outside of the CLR and therefore is not Managed Code! In so far as Native Machine Code, think of Assembler or Machine language to get an idea of what VB6 and such get compiled into. (I don't have any machine code on my computer as that is a very speciliaized skill and I don't know how to program in it nor read it.)
hth.
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
|

March 9th, 2007, 11:43 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
|

May 25th, 2007, 02:23 PM
|
|
Registered User
|
|
Join Date: Nov 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi dparsons,
Great. Thanks for the steps, I was actully looking for this from longtime..
I have a question, What if I want to Deploy a VB.net (VS2005) dll on Server and and I want to access it from Classic ASP and as well as ASP.net 2.0. Is there any extra steps that I need to follow?
|
|

May 25th, 2007, 03:48 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
The steps above should work for 2.0 in acessing the dll from Classic. To access it from ASP.NET just add a reference to it in your application.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
|
|

May 29th, 2007, 09:37 AM
|
|
Registered User
|
|
Join Date: Nov 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi dparsons,
I tried the same way, but when I am trying to access its giving following message,
"File or assembly name MyDOTNET.DLL, or one of its dependencies, was not found."
Any advice?
|
|
 |