Created dll for use in other language
-
Hi all, I work with a very basic lang in a ERP solution. Its an internal development lang. I need to work on a piece of code and realised that C# would be easier than in the internal language. Now I am new to C#. But I create a .dll file and ran regsvr32 on the dll and got the error "CheckDate was loaded, but the dllregisterserver entry point was not found. this file cannot be registered" This is the first time I've tried to create a dll for use externally, and i know I am missing something but not sure what. Any help is greatly appreciated. Regards Tony
-
Hi all, I work with a very basic lang in a ERP solution. Its an internal development lang. I need to work on a piece of code and realised that C# would be easier than in the internal language. Now I am new to C#. But I create a .dll file and ran regsvr32 on the dll and got the error "CheckDate was loaded, but the dllregisterserver entry point was not found. this file cannot be registered" This is the first time I've tried to create a dll for use externally, and i know I am missing something but not sure what. Any help is greatly appreciated. Regards Tony
First of all, if the dll is to be used by other applications/components, what are those apps/components written in? If they're written in a .NET language, there is no need to run regsvr32 on them. However, if the other applications/components are COM components, then you need to do at least 2 things to your C# dll: compile with exposure to COM. From the project settings page in Visual Studio, go to the Build tab and check the "register for COM interop" option. This will build your DLL with COM capability and will register the dll on the local system. If you deploy this dll to another machine, you'll of course need to register it with regsvr32. This article[^] elaborates.
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
-
First of all, if the dll is to be used by other applications/components, what are those apps/components written in? If they're written in a .NET language, there is no need to run regsvr32 on them. However, if the other applications/components are COM components, then you need to do at least 2 things to your C# dll: compile with exposure to COM. From the project settings page in Visual Studio, go to the Build tab and check the "register for COM interop" option. This will build your DLL with COM capability and will register the dll on the local system. If you deploy this dll to another machine, you'll of course need to register it with regsvr32. This article[^] elaborates.
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, Many thanks for that! Damn quick reply. The other language is no where near C# its an internal language called C/AL which is a bit like pascal\C, and is interperated at the time by the application. But it can handle COM objects :-) Many thansk again for the swift reply. Tony
-
First of all, if the dll is to be used by other applications/components, what are those apps/components written in? If they're written in a .NET language, there is no need to run regsvr32 on them. However, if the other applications/components are COM components, then you need to do at least 2 things to your C# dll: compile with exposure to COM. From the project settings page in Visual Studio, go to the Build tab and check the "register for COM interop" option. This will build your DLL with COM capability and will register the dll on the local system. If you deploy this dll to another machine, you'll of course need to register it with regsvr32. This article[^] elaborates.
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
-- modified at 18:14 Monday 16th October, 2006 (fixed so changed as still have error) Okay so I managed to make it build succesfully. But it still won't register. I still get the dllregisterserver entry point error. This is the code, simple I know!
using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace CheckDate { [Guid("1AD0462D-4FA2-4072-B63B-8B1D88212389")] public class CheckDate { private int _day; private int _month; private int _year; 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; } } }
-
-- modified at 18:14 Monday 16th October, 2006 (fixed so changed as still have error) Okay so I managed to make it build succesfully. But it still won't register. I still get the dllregisterserver entry point error. This is the code, simple I know!
using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace CheckDate { [Guid("1AD0462D-4FA2-4072-B63B-8B1D88212389")] public class CheckDate { private int _day; private int _month; private int _year; 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; } } }
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
-
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