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. i can easily call the dll from asp using just those two lines below and from my trusty response. write everything is working fine.
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. so not sure why is it so hard to get it working in asp.net or that i'm just an idiot arggghhh..
using System;
using System.Runtime.InteropServices;
namespace OnlineRegisteration.Models
{
public static class SerialNumberChecksum
{
[DllImport("CTSerialNumChecksum")]
public static extern int ValidateSerialNumber(string serialNo);
}
}
Questions:
- How do i write the class? most example i found didn't involve the class, the .CRC32API part, and those that do seems freaky hard
- And what tool can i use to identify what type of dll a particular file is, i.e. unmanaged c++, etc?
- 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?
Dumpbin call returned me this, not sure why i can't see the validate function name inside:
File Type: DLL
Section contains the following exports for CTSerialNumChecksum.DLL
00000000 characteristics
3D75BB53 time date stamp Wed Sep 04 15:50:43 2002
0.00 version
1 ordinal base
4 number of functions
4 number of names
ordinal hint RVA name
1 0 000015CB DllCanUnloadNow
2 1 000015D7 DllGetClassObject
3 2 000015F1 DllRegisterServer
4 3 00001601 DllUnregisterServer
Summary
5000 .data
2000 .rdata
2000 .reloc
2000 .rsrc
8000 .text
Updates:
Could this be due to name mangling? as it's a c++ dll, at least what i suspect it to be anyway...