Arnkrishn
Arnkrishn

Reputation: 30442

How to reference C# library in ColdFusion?

I have a situation where in I need to reference a C# library in my ColdFusion code. Any suggestions or links would be really useful.

cheers

Upvotes: 1

Views: 1112

Answers (3)

ConsultUtah
ConsultUtah

Reputation: 6829

ColdFusion 8+ supports using .NET classes. Here is an example:

<cfobject
   type = ".NET"
   name = "myInstance"
   class = "myDotNetClass"
   assembly = "C:/Net/Assemblies/dotNetClass.dll"> 
<!--- Call a method--->
<cfset myVar = myInstance.myDotNetClass(5)> 

Upvotes: 7

Marko
Marko

Reputation:

<cfobject type=".NET" name="png" class="blabla" assembly="C:\inetpub\wwwroot\xxx.dll">
 <cfset png.init(181,258)>
 <cfset png.ConvertFile(inputfile1, outputfile1) > 

The init is the same as when you do a new in C# for example:

PNG png = new PNG(181,258);

Then you can execute your methods inside the class like so:

png.ConvertFile(inputfile1, outputfile1)

Upvotes: 0

user134363
user134363

Reputation:

You'll have to make your .Net library COM visible first. In Visual Studio 2008 you can do this by going into your project's properties, Selecting the Application tab, select Assembly Information, and select the checkbox to make assembly COM visible. Make sure that your class is public and not static because I found that the calling programs can't see the static classes. This may not be what you're asking but hope it helps.

If this is a step in what you need then I would suggest searching for using C# .Net libraries in MS Access for info on making your assemblies COM accessible. Although MS Access isn't what you're using there's a lot of info on the topic of assemblies to COM.

Upvotes: 2

Related Questions