How do i transfer this unmanaged code from asp to asp.net 2/mvc?

Posted by melaos on Stack Overflow See other posts from Stack Overflow or by melaos
Published on 2010-04-07T06:38:20Z Indexed on 2010/04/07 6:43 UTC
Read the original article Hit count: 372

Filed under:
|
|
|

hi guys, i'm a newbie to ASP.net interop features, so what i have right here is some unmanaged dll that i need to call from my asp.net mvc app.

the dll name is CTSerialNumChecksum.dll

set CheckSumObj = Server.CreateObject("CTSerialNumChecksum.CRC32API")
validSno        = CheckSumObj.ValidateSerialNumber(no)

i know it's unmanaged because when i try to add reference to the dll it doesn't work. i try to follow some tutorials on interop and marshalling but thus far i wasn't able to get the code to work.

i'm trying to wrap the object into another static class and just let the rest of the app to call the code.

using System;
using System.Runtime.InteropServices;

namespace OnlineRegisteration.Models
{
    public static class SerialNumberChecksum
    {
        [DllImport("CTSerialNumChecksum")]
        public static extern int ValidateSerialNumber(string serialNo);

    }
}

Questions:

  1. How do i write the class?
  2. And what tool can i use to identify what type of dll a particular file is, i.e. unmanaged c++, etc?
  3. Also i intend to make use jquery to do ajax call later so i can use this to validate my form pre-submission. Is there a better way to handle this?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about interop