calling unmanged c-dll from webservice

Discussion in 'ASP .Net Web Services' started by Nicki Carstensen, Sep 6, 2004.

  1. hi all

    I have a class that hooks up to a matlab engine dll that looks something
    like this:
    class MatlabConn
    {
    IntPtr engine;

    DllImport("libeng.dll")]
    static extern IntPtr engOpen(string startcmd);

    MatlabConn()
    {
    engine = engOpen(null);
    if(engine == IntPtr.Zero)
    throw new NullReferenceException("engine creation failed");
    }
    ....
    }
    When the code is used in a winform app it works perfectly, but when i
    try to use it in a webservice, the call til engOpen returns null and
    thus the exception is thrown. engOpen is supposed to start a Matlab
    provcess and as far as I understand it does so via COM but the
    libeng.dll is not a COM-dll itself. I've tried to switch impersonation
    context like this:

    [WebMethod]
    void DoStuff()
    {
    IntPtr hToken;
    LogonUser("Administrator", ".", "pass", 3, 0, out hToken);
    WindowsIdentity id = new WindowsIdentity(hToken);
    WindowsImpersonationContext wic = id.Impersonate();
    MatlabConn matlab = new MatlabConn();
    wic.Undo();
    ....
    }
    Then it works fine, but I'm not very fond of having to use the local
    administrator account directly in code.
    Is there a way to use a non-admin user instead og the admin, or is it
    possible to allow the aspnet/network serivce account to launch the
    matlab process?

    Thanks in advance, and sorry for the novel :)

    Nicki Carstensen
    remove the car in my email
     
    Nicki Carstensen, Sep 6, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UHJhdmVlbiBL?=
    Replies:
    2
    Views:
    4,030
    =?Utf-8?B?UHJhdmVlbiBL?=
    Oct 8, 2004
  2. batista
    Replies:
    1
    Views:
    951
    Laurent Bugnion
    Jan 26, 2006
  3. batista
    Replies:
    0
    Views:
    581
    batista
    Jan 26, 2006
  4. Peter Nordström

    Webservice calling a webservice.....Error

    Peter Nordström, Oct 21, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    183
    Peter Nordström
    Oct 21, 2003
  5. Calling a webservice from a webservice

    , Apr 19, 2005, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    168
Loading...

Share This Page