Not able to refer to Exported Assembly

Engineer2100
Engineer2100 used Ask the Experts™
on
Hi,

       New to C# and to .NET as such. I Created a Small (Code below) and create a PE out of it. I later on moved to exp this Assembly so that I can use it in VB. The process went on smoothly with any error and Hello.tlb was generated. However when I tried to refer under VB IDE, I am not able to do so. Am I doing anything wrong.

Thanks in Advance

Engi
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Have you used RegAsm to register it as a com object ??

Author

Commented:
I had not. But even after doing it now, I am not able to get the name when I type "Dim ObjAsm as < > " Could you please let me now with what name it is listed. I forgot to add the code

using System;

class MyClass      
{
 
      private int s;
      
      public void Msg()
      {
            s = 100;
            Console.WriteLine("Value is {0}",s);
      }
}
class MainApp
{
      public static void Main()
      {
            Console.WriteLine("C# Hello World!");
            MyClass MyCls = new MyClass();
            MyCls.Msg();
      }
}

Will this actually have some class exposed in the first Place?
Regards
Engi
are you able to add the reference to your vb project ?? if so, are you looking in Object Browser for it ??
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Author

Commented:
Yeah I am able to view the Object in Object Browser as "Hello". But the Class in not getting displyed in the intellisense Dropdown.

Regards
Engi
maybe it's in a namespace that isn't in your 'using' list.

Author

Commented:
Sorry could you please eloborate it. As you can see I am importing the System Namespace.
when you go to object browser, is the class displayed within a particular namespace ??

Also, try adding 'public' to your class definitions.

public class MainApp... etc..
Is the assembly included in your References of your VB project?  I'm not too sure about how the VB projects work.

Author

Commented:
Now I am able to see the Class (MyClass) along with the Library Name ("Hello"). But unfortunately not able to instantiate a new MyClass Object. It says "Server Not Registered" When I have registered Hello.Exe using the RegAsm Utility (regasm Hello.exe  /tlb option)


:-(

Engi
Have you tried compiling as a Class Library, i.e. producing a .dll rather than an .exe, then trying to register that ??

Author

Commented:
Nope. I think this is the last resort . Will keep u posted once I do it

Thanks
Engi.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial