qas
asked on
Importing .tbl files
Hi!
I am having trouble importing .tbl files using Delphi 7 and 2005.
I am creating assemblies using Visual Studio .NET which provides a tool to access them as if they where COM objects. This tool creates a .tbl file for the assembly.
When I try to import this file using the "Import Type Library" tool of Delphi I always get this message :
"An error occured while referencing a user defined type. This may be caused by a missing or unregistered type library."
At first I thought that there was a problem with the file itself so I tried to use it with another programming language. I loaded MS-Access, created a form and used the "Reference" menu to add a reference to the .tbl file. Once done, could create objects from my class in my assembly and could easily use the HelloWorld method I implemented for testing purpose. In other words, the tbl seems to work fine.
I tried to import the tbl file with both Delphi 7 and Delphi 2005 without success.
Can anyone help me ?
Thanks!
-Steve
I am having trouble importing .tbl files using Delphi 7 and 2005.
I am creating assemblies using Visual Studio .NET which provides a tool to access them as if they where COM objects. This tool creates a .tbl file for the assembly.
When I try to import this file using the "Import Type Library" tool of Delphi I always get this message :
"An error occured while referencing a user defined type. This may be caused by a missing or unregistered type library."
At first I thought that there was a problem with the file itself so I tried to use it with another programming language. I loaded MS-Access, created a form and used the "Reference" menu to add a reference to the .tbl file. Once done, could create objects from my class in my assembly and could easily use the HelloWorld method I implemented for testing purpose. In other words, the tbl seems to work fine.
I tried to import the tbl file with both Delphi 7 and Delphi 2005 without success.
Can anyone help me ?
Thanks!
-Steve
did you regsvr32 that COM dll?
ASKER
Hi :)
Nope I did not because the dll IS NOT a COM dll, it's a .NET assembly which cannot be registered in the Windows registry but in the Global Assembly Cache.
Microsoft knows that lots of softwares won't be able to use assemblies for a while so they created a tool to interface assemblies as COM objects through a .tbl file. This tool (embedded into Visual Studio, it's just a checkbox labeled something like "Register COM Interop") creates the .tbl file along with the .dll.
And the .tbl actually works! I could use it with MS-Access with no problem and I am pretty sure that if I had an old VB6 on hand I could use it the same way.
Any hint ?
Thanks :)
Nope I did not because the dll IS NOT a COM dll, it's a .NET assembly which cannot be registered in the Windows registry but in the Global Assembly Cache.
Microsoft knows that lots of softwares won't be able to use assemblies for a while so they created a tool to interface assemblies as COM objects through a .tbl file. This tool (embedded into Visual Studio, it's just a checkbox labeled something like "Register COM Interop") creates the .tbl file along with the .dll.
And the .tbl actually works! I could use it with MS-Access with no problem and I am pretty sure that if I had an old VB6 on hand I could use it the same way.
Any hint ?
Thanks :)
could you post that hello world thingie source code so that I can test? I have vs2003 and .net 1.1 and d7/ just never wrote com in vs :)
ASKER
Hi !
Here is what I do (I am translating from a french version of VS so maybe the wording isn't accurate)
--------- Creating the assembly ---------
- New project --> Class library
- Write this code in Class1.vb:
Public Class MyTestClass
Public Sub TestMsg()
MsgBox("TESTTESTTEST")
End Sub
End Class
- Project Properties --> Configuration properties --> Generate (3rd option) --> Check the "Register COM Interop" Checkbox
- Build the project
--------- Testing in Access ---------
- Start Access
- Create new database
- Create new form
- Drop a button on form
- Select an event and select the code generator
- Select Tools --> References...
- Click "Browse"
- Select the .tlb file which is located in the BIN directory of the VS project created earlier
- Make sure the library is checked in the list
- Click OK to get back to code
- Insert this code:
Dim X as New MyTestClass
X.TestMsg
- Run the form, get the TEST message
--------- Testing in Delphi ---------
- Start Delphi, new application
- Select Project --> Import type Library
- Click Add and browse for the .tbl
- Click Create Unit: error!
Thanks!
Here is what I do (I am translating from a french version of VS so maybe the wording isn't accurate)
--------- Creating the assembly ---------
- New project --> Class library
- Write this code in Class1.vb:
Public Class MyTestClass
Public Sub TestMsg()
MsgBox("TESTTESTTEST")
End Sub
End Class
- Project Properties --> Configuration properties --> Generate (3rd option) --> Check the "Register COM Interop" Checkbox
- Build the project
--------- Testing in Access ---------
- Start Access
- Create new database
- Create new form
- Drop a button on form
- Select an event and select the code generator
- Select Tools --> References...
- Click "Browse"
- Select the .tlb file which is located in the BIN directory of the VS project created earlier
- Make sure the library is checked in the list
- Click OK to get back to code
- Insert this code:
Dim X as New MyTestClass
X.TestMsg
- Run the form, get the TEST message
--------- Testing in Delphi ---------
- Start Delphi, new application
- Select Project --> Import type Library
- Click Add and browse for the .tbl
- Click Create Unit: error!
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you have a .NET dll file then :-
C:\WINDOWS\Microsoft.NET\F ramework\v 1.1.4322\r egasm DotNet.dll /tlb:DotNet.tlb
produces a .tbl file which one can import or process to IDL etc....
C:\WINDOWS\Microsoft.NET\F
produces a .tbl file which one can import or process to IDL etc....
ASKER
well I feel stupid...
Whether my Delphi or .NET installation must be corrupted because I tried on another machine and it worked fine on my first attempt.
By the way, to get the TestMsg function working in Delphi you have to create an Interface and the implement it in the class first (in Visual Studio). It is the interface that will hold the function's declaration.
Thanks :)
Whether my Delphi or .NET installation must be corrupted because I tried on another machine and it worked fine on my first attempt.
By the way, to get the TestMsg function working in Delphi you have to create an Interface and the implement it in the class first (in Visual Studio). It is the interface that will hold the function's declaration.
Thanks :)