What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » C# Dlls in scripts

C# Dlls in scripts
Author: Message:
Hilikus
Junior Member
**


Posts: 27
42 / Male / –
Joined: Apr 2005
O.P. C# Dlls in scripts
How do i call a function from a dll that was written in C#? interop.Call requires the name of the function, but in C# you have namespaces and everything is object oriented. Functions are not in a global or standard namespace as you could have in c++ so the second parameter of Call() should be what??
any help would be appreciated

I saw another C# program using the dll i want to use but of course, what they did was a "using" directive and then created an instance of the class that's in the dll

i would like to do that, create an object of the class OR (since i have the source code of the dll) i can add a function that creates a local instance and gives me all i need, but again, with interop.Call i cant do that because the function is not in a global namespace so i cant call it directly

Thanks a lot
07-31-2006 04:21 AM
Profile E-Mail PM Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: C# Dlls in scripts
You need to use regasm, which allows .net classes to be used like COM classes, to register your dll, and in your Javascript, just do this:

var classInstanceVar=new ActiveXObject("NamespaceName.ClassName");

to instantitate your class. Then you can manipulate the instance, object-orientedly :)

This post was edited on 07-31-2006 at 10:57 AM by Mnjul.
07-31-2006 10:55 AM
Profile PM Web Find Quote Report
Hilikus
Junior Member
**


Posts: 27
42 / Male / –
Joined: Apr 2005
O.P. RE: C# Dlls in scripts
oh ok, that worked out well after some research and testing but there is still one thing. activexObject calls the default constructor, what if i want to call a constructor with parameters?? any help would be appreciated since i havent been able to find anything
08-01-2006 02:00 AM
Profile E-Mail PM Find Quote Report
Adeptus
Senior Member
****


Posts: 732
Reputation: 40
Joined: Oct 2005
RE: C# Dlls in scripts
quote:
Originally posted by Hilikus
activexObject calls the default constructor, what if i want to call a constructor with parameters??
Sorry, you can't.  Classes instantiated through COM interop must have a default (public, parameterless) constructor.

You should be able to easily work around this in most cases, by providing properties to set whatever you would have set through constructor's parameters. 

Where that isn't possible (you are using somebody else's class or it is essential to your logic to have the parameter passed at creation time), use a helper class with a public method which takes the parameters, creates the class instance passing parameters to the constructor, and returns the created object.
08-01-2006 02:58 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On