Wrox Programmer Forums
|
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
 
Old March 21st, 2006, 08:54 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default 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
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
 
Old March 27th, 2006, 05:33 AM
Authorized User
 
Join Date: Mar 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old December 7th, 2006, 10:28 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

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
 
Old December 8th, 2006, 02:53 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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
 
Old December 12th, 2006, 08:39 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

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
 
Old December 12th, 2006, 09:36 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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
 
Old March 9th, 2007, 11:43 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

thanks mate

www.crmpicco.co.uk
www.ie7.com
 
Old May 25th, 2007, 02:23 PM
Registered User
 
Join Date: Nov 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?

 
Old May 25th, 2007, 03:48 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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
================================================== =========
 
Old May 29th, 2007, 09:37 AM
Registered User
 
Join Date: Nov 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?






Similar Threads
Thread Thread Starter Forum Replies Last Post
classic asp with asp.net on same iis bostonrose .NET Framework 2.0 6 January 10th, 2007 12:38 PM
accessing MS SQL DB from Classic ASP script crmpicco SQL Server ASP 2 June 1st, 2006 03:43 PM
Problem accessing a .dll component in asp.net page ng4123 ASP.NET 1.0 and 1.1 Basics 5 May 10th, 2006 07:31 AM
CLassic ASP in Visual Studio.NET rodmcleay ASP.NET 1.0 and 1.1 Professional 2 September 6th, 2004 08:06 PM
Best Practise for VS.NET IDE and Classic ASP rodmcleay Classic ASP Professional 1 September 3rd, 2004 03:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.