Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access VB 'Object' from C#

Status
Not open for further replies.

dcparizo

Programmer
Feb 17, 2005
6
0
0
US
Having trouble with old code written in vb 6 or (gasp)earlier. The problem is that the return objects are of type "Object".

When ever I try to cast the "Object" to a new type, I get the fact that either the type is not registered or one of a variety of other messages.

If I try to create an the target object in C# first, the object creates, but then the call to the DLL to create the object says that It cannot do an implicit cast to the object type e.g. Cannont implicity cast type 'Object' to type 'X'.

Any help would be great.
Thanks
 
You need to create a "wrapper" for the COM assembly. VisualStudio.NET will do this for you automatically when you add a reference to it using the "Add Reference" dialog and select your dll on the COM tab. Once the wrapper is created, you can create instance of the types available in it in your .NET code.

[pipe]
Share your knowledge! -
 
I did try to add and create the com wrapper, but. I also should mention. that the original file is a .tlb file. (don't know if that makes a difference.)

The additional problem seems to be the lack of reg entries for a variety of objects contained.

eg appobject, projectobject. The app has a reg entry for interface and classes interface.

but no other classes seem to have this, so to follow up how do I get the applicable information.


Here's the actual code and error message
-- code --

OEApp AppObject = new ApOLEApp.OEApp();
ApOLEApp.OEProject Proj = new ApOLEApp.OEProject();


--error message --
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in RTUScripts.exe

Additional information: COM object with CLSID {BC95E400-3874-101C-95EA-04021C007002} is either not valid or not registered.



(again trying this in C#.net vs vb.net)
Thanks in advance.
 
PS. To last message... It's the second line that throws the error.

thanks in advance
 
If you have a .tlb file, run tlbimp.exe to create an import file.

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thanks Chip.

I had already tried this once. But tried again with
same results.

Created the dll via the above mentioned utility and still returns same error.

It just doesn't seem to like this code.

thanks for the attempt.

Dan
 
Got it to work ... I reloaded .net and followed through
the procedures again and all was fine.

thanks for all the help.

Dan
 
dcparizo, how did you solve this problem? I too have been scripting the Aperture client with VB6 and have been trying to move to a .NET platform instead. I am getting similar errors on a very similar line. Which procedures did you follow through?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top