473,698 Members | 2,869 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling a C# component from Classic ASP

Hi Gang,

I've created a C# .NET component which transforms a .TIF file into a .JPEG
file. I have a classic ASP website in which I wish to call this C#
component from my classic ASP.

Can anyone point me in the right direction as to how this may be done. I'm
hungry for some guidance as I can't go forward until this is sorted.

Thanks heaps everyone.
Ben O
Nov 17 '05 #1
3 14305
You can expose your class via COM for use in ASP:

On your class declare a System.Runtime. InteropServices .GuidAttribute( "[guid goes here]"). You can obtain a Guid in the appropriate
format by using VS.NET. Go to Tools --> Create GUID. This assigns your soon-to-be COM object that can be used in ASP a unique GUID
that will be registered with Windows.

Your class will be registered with an automattically generated ProgID made up of the Namespace and Class name and with the GUID you
have assigned using the GuidAttribute. Use the ProgIdAttribute if you wish to hard-code a programmatic identifier for your class.

It is recommended that you hard-code the GUID since VS.NET will generate one for you otherwise and it will change upon successive
builds. If neither a ProgID or Guid is specified for your class, it will not be registered for COM Interop unless you specify the
ComVisible attribute as System.Runtime. InteropServices .ComVisible(tru e).

Again, I recommend just using the GuidAttribute stand-alone.

In the Project settings dialog of the project that contains your class, select the "Configurat ion Properites" node, then "Build"
node and set "Register for COM Interop" = "true".

When you build your application, VS.NET will register your assembly for COM interop by checking for classes with the attributes I've
mentioned above and if appropriate, registering them with Windows.

This is the command-line utility that you can use to do this manually:

%windir%\Micros oft.NET\Framewo rk\v1.1.4322\Re gAsm.exe

In ASP create an instance of the object as you would using a ProgID, for example, with an ADODB.Connectio n. Here is how you would
access your object via scripting if your class was in the namespace, "MyNamespac e" and was named, "MyClass":

vbscript:
Dim conn: Set conn = CreateObject("M yNamespace.MyCl ass");
JScript:
var conn = new ActiveXObject(" MyNamespace.MyC lass");

Note that for production servers your going to have to register the assembly manually since it's not a good idea to install VS.NET
and build on live servers. Check out the RegAsm.exe utility that I've mentioned above. It's a command-line utility only.

I suggest creating a Setup and Deployment project for your web site if you are going to be using a live server, and automate the
registration using the installer.
--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"Ben O via DotNetMonster.c om" <fo***@nospam.D otNetMonster.co m> wrote in message
news:91******** *************** *******@DotNetM onster.com...
Hi Gang,

I've created a C# .NET component which transforms a .TIF file into a .JPEG
file. I have a classic ASP website in which I wish to call this C#
component from my classic ASP.

Can anyone point me in the right direction as to how this may be done. I'm
hungry for some guidance as I can't go forward until this is sorted.

Thanks heaps everyone.
Ben O

Nov 17 '05 #2
In addition to Dave's helpful comments remember that the server must be
running IIS and the .NET framework in order to host your .NET DLL.

You cannot for example put your DLL onto an ASP server running a non windows
OS or without IIS and the framework.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Ben O via DotNetMonster.c om" <fo***@nospam.D otNetMonster.co m> wrote in
message news:91******** *************** *******@DotNetM onster.com...
Hi Gang,

I've created a C# .NET component which transforms a .TIF file into a .JPEG
file. I have a classic ASP website in which I wish to call this C#
component from my classic ASP.

Can anyone point me in the right direction as to how this may be done. I'm
hungry for some guidance as I can't go forward until this is sorted.

Thanks heaps everyone.
Ben O

Nov 17 '05 #3
Create a COM callable wrapper to your C# Component and register it via VS.Net
or regasm

"Bob Powell [MVP]" wrote:
In addition to Dave's helpful comments remember that the server must be
running IIS and the .NET framework in order to host your .NET DLL.

You cannot for example put your DLL onto an ASP server running a non windows
OS or without IIS and the framework.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Ben O via DotNetMonster.c om" <fo***@nospam.D otNetMonster.co m> wrote in
message news:91******** *************** *******@DotNetM onster.com...
Hi Gang,

I've created a C# .NET component which transforms a .TIF file into a .JPEG
file. I have a classic ASP website in which I wish to call this C#
component from my classic ASP.

Can anyone point me in the right direction as to how this may be done. I'm
hungry for some guidance as I can't go forward until this is sorted.

Thanks heaps everyone.
Ben O


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2097
by: paulette | last post by:
I have read a zillion and one posts on this exact same problem, but none of them has suggested anything that works for me. So... I am using .Net Framework Version 1.1.4322 I have: 1. Created a C# Class Library project and tested it. It generates the correct output when I use it from a tester class from another project in the same solution 2. Generated a key and inserted the correct key information into the
3
2578
by: Alan | last post by:
Gidday people, I had a bit of a problem this morning. I think I've got it sorted now, but I wonder if anyone can shed some light. I have a plain VBS WHS file that instantiates a component that controls an interface file import process. This component, Controller, is part of FinInterface.dll, and instantiates another component, Implementor (same dll), that does the actual data access (an insert into a FinanceDataImports table, and then...
0
1903
by: Johan Lachonius | last post by:
Hi, I'm using a "classic" asp-page and a .net-component which I want to call passing a Recordset as a parameter. I have a reference to ADODB in the .net component which should supply a COM rapper for a Recordset. In the .net component code looks like: using ADODB: public void MyFunction( Recordset rs )
6
6176
by: Patrick | last post by:
Following earlier discussions about invoking a .NET class library via ..NET-COM Interop (using regasm /tlb) at http://groups.google.com/groups?hl=en&lr=&threadm=%23Van7eSrEHA.4004%40TK2MSFTNGP10.phx.gbl&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26selm%3D%2523Van7eSrEHA.4004%2540TK2MSFTNGP10.phx.gbl I have concluded that my .NET class library (following the suggestions. namely setting the marshall type, etc.) , I can 1) Invoke public methods...
99
6114
by: Jim Hubbard | last post by:
It seems that Microsoft not only does not need the classic Visual Basic developer army (the largest army of developers the world has ever seen), but now they don't need ANY Windows developer at a small or mid-sized business. http://groups-beta.google.com/group/microsoft.public.msdn.general/browse_thread/thread/9d7e8f9a00c1c7da/459ca99eb0e7c328?q=%22Proposed+MSDN+subscription+changes%22&rnum=1#459ca99eb0e7c328 Damn! To be that...
1
1468
by: Jim Hammond | last post by:
The following code uses a client-side component to capture an image from the camera on the client system. The problem is that the init function (in ClientSideAssembly_Video.dll) is called once when the page is first displayed and then each time the button is pressed. I'm guessing that the component is being instantiated each time. Is there any way to keep using the same instance?
1
2096
by: AnRonMor | last post by:
Currently I use the MS Soap Toolkit to expose some 20 or so com objects for use by classic asp pages, this has to be replaced as support is ending. I have found two proposed solutions below and would appreciate any comments, particularly from somone who has done this before. Create a .net WS to expose the Com Objects >From searching the web it looks like a couple of options are available to access the web service from classic asp:
1
1769
by: tristanpc | last post by:
Hi, I've got to the Hello World stage of wrapping a .net component with a CCW and calling it from wscript.exe. By placing the .tlb and .dll in the same folder as wscript I get this to work (I realise I have to do GAC stuff to get it recognised when not in the same folder). My problem is calling my new component from classic ASP. I just can't get this to work. I don't get an ActiveX can't create object error but I do get an error...
1
3568
by: wanaruk | last post by:
Hi all. I am working on a legacy application written in Classic ASP with VB6 COM+ components running on Windows 2003 Adv Server (32bit). There is one page in the app that uses Secure FTP to send a file to another application server upon a certain type of data change. The way it works: Anonymous user posts the form - ASP code instantiates the COM+ component which is starting using a Domain User -Calls a method that creates the comma...
0
9157
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9026
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4366
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.