Shoutbox

[?] C#.net dll and ActiveXObject - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [?] C#.net dll and ActiveXObject (/showthread.php?tid=69491)

[?] C#.net dll and ActiveXObject by Felu on 12-14-2006 at 12:39 PM

I made a dll in C#.net with MS Visual C# 2005 Express Edition. When i declare the ActiveXObject it gives either of the two errors.

code:
Error: unknown.
       Line: 4. Code: -2147024894.
or
code:
Error: Automation server can't create object.
       Line: 4. Code: -2146827859.

-The dll is COM Visible
-The dll is registered with ResAsm utility and is also placed in <DotNetFiles> in the ScriptInfo.xml
-A GUID is registered.

I've read other threads on the forum, some of them having the same problem. But none have a working solution :sad:.

Any help is appreciated :wink:
RE: [?] C#.net dll and ActiveXObject by Deco on 12-14-2006 at 12:57 PM

Great thread. Same problem here.

Would you send me some c# code so I see if I'm doing something wrong there? I'm not even sure my dll is COM visible.


RE: [?] C#.net dll and ActiveXObject by Felu on 12-14-2006 at 01:06 PM

Sample code i'm using

code:
public string Return(string strString)
        {
            return strString;
        }
And to make an assembly COM visible in Visual C# 2005. Projects > Application > Assembly Information > Make Assembly COM Visible.
RE: [?] C#.net dll and ActiveXObject by Deco on 12-14-2006 at 01:07 PM

Thanks :) I'm trying some things here if I succeed I'll make sure to let you know


RE: [?] C#.net dll and ActiveXObject by Chestah on 12-14-2006 at 01:16 PM

I can't exactly remember how i got my C# dlls to work, but theres another process you have to do to the actual code itself to get it "visible" and able to be registered. I'm fairly sure i learnt how to do it from a tutorial on the codeproject website.

Sorry, but i hope this helps :).

Edit: Heres a .dll i made to use with Plus! live, having a look at the format you may beable to copy it and make your dll accessible.

The project name was "MPL".

code:
using System;
using System.Collections;
using System.Text;
using System.Runtime.InteropServices;

namespace CS
{
    [Guid("D6F88E95-8A27-4ae6-B6DE-0542A0FC7039")]
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]

    public interface _Functions
    {
        [DispId(1)]
        string DoSearch(string query, int resultsnum);
    }



    [Guid("13FE32AD-4BF8-495f-AB4D-6C61BD463EA4")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("MPL.Functions")]
    public class Functions : _Functions
    {
        public string DoSearch(string query, int resultsnum)
        {
            //example code
        }
    }
}

I'd personally recommend staying away from ActiveX dlls and use as much Jscript as you can.
RE: [?] C#.net dll and ActiveXObject by Deco on 12-14-2006 at 01:34 PM

If I make a dll out of that..

var msg = Interop.Call("c:\\Projects\\sendMsg\\teste.dll","DoSearch","feio",2);

Calling it like that...

Interop.Call failed to locate function "DoSearch"

is what I get.


RE: [?] C#.net dll and ActiveXObject by -dt- on 12-14-2006 at 01:44 PM

quote:
Originally posted by Deco
If I make a dll out of that..

var msg = Interop.Call("c:\\Projects\\sendMsg\\teste.dll","DoSearch","feio",2);

Calling it like that...

Interop.Call failed to locate function "DoSearch"

is what I get.

:-/ thats for a COM dll though, Interop.Call is for dlls which export their functions.

you use the following for COM

code:
var obj = new ActiveXObject("name.id");


RE: [?] C#.net dll and ActiveXObject by Deco on 12-14-2006 at 02:00 PM

Ok that was it...
Thanks


RE: [?] C#.net dll and ActiveXObject by Felu on 12-16-2006 at 05:00 AM

Read many articles on The Code Project, none of them could help me to get rid of the unknown error [Image: xso_sad.gif].


RE: [?] C#.net dll and ActiveXObject by ShawnZ on 12-16-2006 at 05:05 AM

quote:
Originally posted by -!Felu!-
Read many articles on The Code Project, none of them could help me to get rid of the unknown error [Image: xso_sad.gif].

* ShawnZ sighs

why are you searching so specifically? why not search for something like "C# COM ActiveX Expose" or sometihng :-/
RE: [?] C#.net dll and ActiveXObject by RaceProUK on 12-16-2006 at 11:07 AM

quote:
Originally posted by -!Felu!-
-The dll is COM Visible
-The dll is registered with ResAsm utility and is also placed in <DotNetFiles> in the ScriptInfo.xml
Why do I get the feeling it's this that's causing issues? Granted, I'm not familiar with all the Scripting API, but surely trying to load the DLL as a COM object when it's also exposed as a .NET assembly may be causing problems?
RE: [?] C#.net dll and ActiveXObject by Felu on 12-17-2006 at 05:23 AM

quote:
Originally posted by RaceProUK
quote:
Originally posted by -!Felu!-
-The dll is COM Visible
-The dll is registered with ResAsm utility and is also placed in <DotNetFiles> in the ScriptInfo.xml
Why do I get the feeling it's this that's causing issues? Granted, I'm not familiar with all the Scripting API, but surely trying to load the DLL as a COM object when it's also exposed as a .NET assembly may be causing problems?
Scripts support COM objects and not .NET(as far as i know) so the dll has to be COM Visible.

Scripting contest ends day after and i haven't been able to solve my dll's problem ;<. Help me!!!!

Edit : I just found out that MP!L when registers the dll doesn't add it to Global Assembly Cache resulting in failing of the dll
RE: [?] C#.net dll and ActiveXObject by Chestah on 12-17-2006 at 08:02 AM

quote:
Originally posted by -!Felu!-
Edit : I just found out that MP!L when registers the dll doesn't add it to Global Assembly Cache resulting in failing of the dll

So are you saying .Net/COM dll's don't work because of a plus problem :O?
RE: [?] C#.net dll and ActiveXObject by Felu on 12-17-2006 at 08:04 AM

quote:
Originally posted by Chestah
quote:
Originally posted by -!Felu!-
Edit : I just found out that MP!L when registers the dll doesn't add it to Global Assembly Cache resulting in failing of the dll

So are you saying .Net/COM dll's don't work because of a plus problem [Image: msn_surprised.gif]?
In a way, yes.
RE: [?] C#.net dll and ActiveXObject by Chestah on 12-17-2006 at 08:10 AM

I'd bring Patchou's attention to the problem. If it is a Plus! problem i'm sure he'd allow your scripts entry into the competition by the due date or give you until he fixes the problem.