Search code examples
asp.netvb.netreference.net-assemblyinline-code

Referencing class library in inline vb code


I'm working on a legacy vb.net application that does most of its work using inline code (

Within that script I need to access functions from a third party .net dll.

The dll(s) themself are stored in the GAC.

Before I started the page looked something like the following

<script runat="server">    
    Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        '''code here    
    End Sub
</script>

For instance say the dll is called Foo.dll and I need to access the Bar class and the .Run() method

ie.

<script runat="server">    
    Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim bar as Foo.Bar = new Foo.Bar()
        bar.Run()
    End Sub
</script>

I have tried to reference the dlls using

<%@ Import Namespace="Foo" %>

in the same place as the other imports however I receive the following

error BC30002: Type 'Foo.Bar' is not defined

Is there some other way I should be refering this third party dll, I'm mostly a C# guy and haven't dealt much with VB or this kind of inline code. Note the code I have shown is all from a user control (.ascx)


Solution

  • Turns out I needed to add

    <%@ Assembly Name="Foo, Version=x.x.x.x, Culture=neutral, PublicKeyToken=sfgfdsgfdsgsdg" %>
    

    as it was in the gac and not being automatically referenced