Created dll for use in other language
-
I haven't done this in awhile, so my memory is a little foggy. A couple things jump out at me: I believe you'll need an interface declared that defines the functionality you want available in COM. Something like:
[Guid("03AD5D2D-2AFD-439f-8713-A4EC0705B4D9")]
interface ICheckDate
{
void DoThis();
void DoThat();
}Then have you class implement that interface. I think you'll need the ClassInterface attribute on your class as well. Your class declaration should look like this:
[ClassInterface(ClassInterfaceType.None), Guid("1AD0462D-4FA2-4072-B63B-8B1D88212389")]
public class CheckDate : ICheckDate
{
...
}I'm a little fuzzy on this though whole .NET-to-COM interop, so take it with a grain (or generous helping ;P) of salt. p.s. next time try <pre> tags around your code snippets. *edit* Looking at that article[^] again, it seems you need to call regasm tool to register the .NET assembly. I'd definitely check out that article and see for sure what needs to be done.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: God-as-Judge, God-as-Forgiver The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
well, I tried that too, but no success. Doh.
using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace CheckDate { [Guid("2BE56F71-BC00-4736-8D85-9A3C6438CDA7")] interface ICheckDate { bool checkDate(); void clear(); } [ClassInterface(ClassInterfaceType.None), Guid("1AD0462D-4FA2-4072-B63B-8B1D88212389")] public class CheckDate : ICheckDate { public int day { set { _day = value; } } public int month { set { _month = value; } } public int year { set { _year = value; } } public bool checkDate() { DateTime newDateTime; string dateString; dateString = _day.ToString() + _month.ToString() + _year.ToString(); if (DateTime.TryParse(dateString,out newDateTime)) return true; else return false; } public void clear() { _day = 0; _month = 0; _year = 0; } } }
-
well, I tried that too, but no success. Doh.
using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace CheckDate { [Guid("2BE56F71-BC00-4736-8D85-9A3C6438CDA7")] interface ICheckDate { bool checkDate(); void clear(); } [ClassInterface(ClassInterfaceType.None), Guid("1AD0462D-4FA2-4072-B63B-8B1D88212389")] public class CheckDate : ICheckDate { public int day { set { _day = value; } } public int month { set { _month = value; } } public int year { set { _year = value; } } public bool checkDate() { DateTime newDateTime; string dateString; dateString = _day.ToString() + _month.ToString() + _year.ToString(); if (DateTime.TryParse(dateString,out newDateTime)) return true; else return false; } public void clear() { _day = 0; _month = 0; _year = 0; } } }
Did you try running regasm on the assembly instead of regsvr32?
Tech, life, family, faith: Give me a visit. I'm currently blogging about: God-as-Judge, God-as-Forgiver The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
Did you try running regasm on the assembly instead of regsvr32?
Tech, life, family, faith: Give me a visit. I'm currently blogging about: God-as-Judge, God-as-Forgiver The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
Hi Judah, I did, but I need to ship the DLL out to another machine as well, so I am assuming they would need to use regsvr32. hence trying that.
Microsoft (R) .NET Framework Assembly Registration Utility 2.0.50727.42 Copyright (C) Microsoft Corporation 1998-2004. All rights reserved. Types registered successfully
-
Hi Judah, I did, but I need to ship the DLL out to another machine as well, so I am assuming they would need to use regsvr32. hence trying that.
Microsoft (R) .NET Framework Assembly Registration Utility 2.0.50727.42 Copyright (C) Microsoft Corporation 1998-2004. All rights reserved. Types registered successfully
You'll need to register it on the target machine with regasm, I believe. .NET needs to be installed on the target machine too, so regasm will be there if .NET is installed.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: God-as-Judge, God-as-Forgiver The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
You'll need to register it on the target machine with regasm, I believe. .NET needs to be installed on the target machine too, so regasm will be there if .NET is installed.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: God-as-Judge, God-as-Forgiver The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
I used the REGASM on my local machine, but I still can't see the custom control in my internal DB langauage. Once registered, they normally show. Any other way to test if its been implemented? T
I have some old .NET-to-COM code along with steps to register it somewhere. I'll see if I can dig that up tomorrow. p.s. as I understand it, regasm has an optional argument you can pass it to generate a tlb file from the assmebly. If you do that, can you use the resulting tlb file in regsvr32?
Tech, life, family, faith: Give me a visit. I'm currently blogging about: God-as-Judge, God-as-Forgiver The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
I have some old .NET-to-COM code along with steps to register it somewhere. I'll see if I can dig that up tomorrow. p.s. as I understand it, regasm has an optional argument you can pass it to generate a tlb file from the assmebly. If you do that, can you use the resulting tlb file in regsvr32?
Tech, life, family, faith: Give me a visit. I'm currently blogging about: God-as-Judge, God-as-Forgiver The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
Checkdate.tlb is not an executable file and no registration helper is registered for this file type.
:confused: Thanks for all the help by the way I appreciate it! T
If you use a tool like OleView or some other COM object viewer, your regasm'd dll doesn't show up on the target system? It should! :-p
Tech, life, family, faith: Give me a visit. I'm currently blogging about: God-as-Judge, God-as-Forgiver The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
If you use a tool like OleView or some other COM object viewer, your regasm'd dll doesn't show up on the target system? It should! :-p
Tech, life, family, faith: Give me a visit. I'm currently blogging about: God-as-Judge, God-as-Forgiver The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
Hi Judah, I just downloaded oleview to see, and it is there :-) Just can't see it in my DB langauge. damn it. Oh and when I try to expand it in Oleview it complains at me COGetClassObject failed. The system cannot find the file specified. severity: SEVERITY_ERROR, facility: FACILITY_WIN32($80070002) T
-
Hi Judah, I just downloaded oleview to see, and it is there :-) Just can't see it in my DB langauge. damn it. Oh and when I try to expand it in Oleview it complains at me COGetClassObject failed. The system cannot find the file specified. severity: SEVERITY_ERROR, facility: FACILITY_WIN32($80070002) T
Nooie, I'm afraid I've given you all the help I know how. Maybe someone else knows where you're going wrong. Yeah, AFAIK, doing regasm on the dll built with all the specs we just went over should work. I'm afraid I don't have any other ideas.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: God-as-Judge, God-as-Forgiver The apostle Paul, modernly speaking: Epistles of Paul Judah Himango