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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Global Assembly Cache Problem

Status
Not open for further replies.

nbruckelmyer

Programmer
May 28, 2003
6
US
I cannot get GAC to work. If you see I did anything wrong, please let me know.
Here is my file

**********hwmod2.vb******************
Imports System
Imports System.Reflection


<assembly:AssemblyVersionAttribute(&quot;1.0.0.0&quot;)>
<assembly:AssemblyKeyFileAttribute(&quot;hwmod2.snk&quot;)>

Namespace HW
Public Class Test
Public Sub Hello(strLang As String)
If strLang = &quot;SP&quot; Then
System.Console.WriteLine(&quot;Hola&quot;)
Else
System.Console.WriteLine(&quot;Hello&quot;)
End If
End Sub
End Class
End Namespace
***************************************

I create my key using -
sn -k hwmod2.snk

I then compile the file using -
vbc /out:hwmod2.dll /t:library hwmod2.vb

I then install the file into GAC -
gacutil /i hwmod2.dll

Everything has worked fine till here.
I create my test file in another folder.

********* MyTest.vb************
Imports HW

Namespace MyTest
Public Class Test
Public Sub Test()
hw.Hello(&quot;hi&quot;)
End Sub
End Class
End Namespace
*****************************

I get this error when I try to compile this file. Any ideas.

vbc MyTest.vb


************* Here is my error msg***********************
Microsoft (R) Visual Basic .NET Compiler version 7.00.9466
for Microsoft (R) .NET Framework version 1.00.3705
Copyright (C) Microsoft Corporation 1987-2001. All rights reserved.

vbc : error BC30420: 'Sub Main' was not found in 'MyTest'.
C:\GAC\test\MyTest.vb(1) : error BC30466: Namespace or type 'HW' for the Imports
'HW' cannot be found.

Imports HW
~~
C:\GAC\test\MyTest.vb(4) : error BC30001: Statement is not valid in a namespace.


Dim h As New HW()
~~~~~~~~~~~~~~~~~
C:\GAC\test\MyTest.vb(7) : error BC30451: Name 'h' is not declared.

h.Hello(&quot;hi&quot;)
~
****************************************************

Please help me if you can.

Thanks.
 
If you have a class Test in namespace HW, and you have another one named Test in namespace MyTest, how can the compiler tell them apart?

Try this:
Code:
Imports HW

Namespace MyTest
  Public Class TT-Test
    Public Sub TT-Test() 
      Dim objTest as New Test  ' from namespace HW
      objTest.Hello(&quot;hi&quot;)
    End Sub
  End Class
End Namespace

Chip H.

 
I tried your code and here is what I got

vbc : error BC30420: 'Sub Main' was not found in 'MyTest'.
C:\GAC\test\MyTest.vb(1) : error BC30466: Namespace or type 'HW' for the Imports
'HW' cannot be found.

Imports HW
~~
C:\GAC\test\MyTest.vb(4) : error BC30205: End of statement expected.

Public Class TT-Test
~~~~~
C:\GAC\test\MyTest.vb(5) : error BC30205: End of statement expected.

Public Sub TT-Test()
~~~~~~~
C:\GAC\test\MyTest.vb(6) : error BC30002: Type 'Test' is not defined.

Dim objTest as New Test ' from namespace HW
 
OK, one error at a time:

You need to declare a Sub Main to act as the entry point to your program, and set your project properties so that .NET knows to start there.

The other &quot;end of statement&quot; errors could be a cut and paste error, or could be related to that the class is named TT-Test while the source file is named &quot;MyTest&quot;.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top