none
Writeing a data extention. RRS feed

  • Question

  • Hello I recently made a VERY Simple Smallbasic extension. but it wont work. I followed the PDF to the letter but, it still wont work. got any ideas? I have smallbasic ver 0.1 and here is my source code.

    Imports Microsoft.SmallBasic.Library
    ''' <summary>
    ''' This is my test extension
    ''' </summary>
    <SmallBasicType()>
    Public Class TestExtension
        ''' <summary>
        ''' Add two numbers
        ''' </summary>
        ''' <param name="value1">First value</param>
        ''' <param name="value2">Second value</param>
        ''' <returns>The sum</returns>
        Public Function Add(ByVal value1 As Primitive, ByVal value2 As Primitive) As Primitive
            Return value1 + value2
        End Function
    End Class

    It biulds it but small basic won't run the Dll. Thanks!


    One thing that is impossible is impossible no matter if it is proven so first.


    Monday, August 27, 2012 6:44 PM
    Answerer

Answers

  • This looks like my mistake - if you are copying my howto - Replace Class with Module.

    Imports Microsoft.SmallBasic.Library
    
    ''' <summary>
    ''' This is my test extension
    ''' </summary>
    <SmallBasicType()>
    Public Module TestExtension
        ''' <summary>
        ''' Add two numbers
        ''' </summary>
        ''' <param name="value1">First value</param>
        ''' <param name="value2">Second value</param>
        ''' <returns>The sum</returns>
        Public Function Add(value1 As Primitive, value2 As Primitive) As Primitive
            Return value1 + value2
        End Function
    End Module

    • Marked as answer by Zock77Editor Monday, August 27, 2012 7:08 PM
    Monday, August 27, 2012 7:02 PM
    Moderator

All replies

  • This looks like my mistake - if you are copying my howto - Replace Class with Module.

    Imports Microsoft.SmallBasic.Library
    
    ''' <summary>
    ''' This is my test extension
    ''' </summary>
    <SmallBasicType()>
    Public Module TestExtension
        ''' <summary>
        ''' Add two numbers
        ''' </summary>
        ''' <param name="value1">First value</param>
        ''' <param name="value2">Second value</param>
        ''' <returns>The sum</returns>
        Public Function Add(value1 As Primitive, value2 As Primitive) As Primitive
            Return value1 + value2
        End Function
    End Module

    • Marked as answer by Zock77Editor Monday, August 27, 2012 7:08 PM
    Monday, August 27, 2012 7:02 PM
    Moderator
  • Thanks!

    One thing that is impossible is impossible no matter if it is proven so first.


    • Edited by Zock77Editor Wednesday, September 26, 2012 7:27 PM
    Monday, August 27, 2012 7:09 PM
    Answerer
  • If you need any more help writing extentions, ask me... I may be of assistance. :)

    -Noah J. Buscher "Nothing is Impossible Until Proven Impossible."

    Monday, August 27, 2012 10:44 PM
  • I used the above extension as suggested by Litdev.  Created the .dll and the .xml files and copied them into the lib folder.  SB doesn't pick this up though.  I used ILSPY to look at the .dll file and it looks OK to me.  Below is how it shows from the .dll via ILSPY.

    Imports Microsoft.SmallBasic.Library
    Imports Microsoft.VisualBasic.CompilerServices
    Imports System

    Namespace ClassLibrary1
     <SmallBasicType()>
     Public Module TestExtension
      Public Function Add(value1 As Primitive, value2 As Primitive) As Primitive
       Return value1 + value2
      End Function
     End Module
    End Namespace

    I know that the Lib folder is right as I can put the Data extension in and it works OK. Any idea as to why this doesn't work?

    In SB I put in TestExtension.Add(2,3) and it come back with cannot find object "TestExtension".

    Thanks,

    JR


    JR

    Sunday, September 2, 2012 6:12 PM
    Answerer
  • The ILSpy code looks OK to me.

    Don't name your SmallBasic file the same as the dll extension, NOT TestExtension.sb (unlikely you did this but it causes conflicts).

    Finally, I assume you are targeting .Net3.5 - did you follow the step-by-step guide I uploaded which covers this?  If not try that.

    To test further you may have to upload the source project (zip up the entire solution folder).
    Sunday, September 2, 2012 7:12 PM
    Moderator
  • Don't name your SmallBasic file the same as the dll extension, NOT TestExtension.sb (unlikely you did this but it causes conflicts).

    For anyone wondering what will happen, it will throw a TypeLoadException because you can't have a library (.dll) and an executable (.exe) with the same name due to (presumably) the CLR confusing them and conflicts occurring.
    Sunday, September 2, 2012 7:19 PM
  • LitDev,

    Where is your step by step guide?  I've seen it mentioned, but haven't found it.

    JR


    JR

    Sunday, September 2, 2012 7:24 PM
    Answerer
  • All my stuff is here

    The getting started guide is in the "Other Resource Downloads" section, called "Guide to writing extensions", just hit to download.

    Sunday, September 2, 2012 8:03 PM
    Moderator
  • Litdev,

    Problem was I was not pointing the compiler to Net 3.5.

    Thanks for the help,

    JR


    JR

    Sunday, September 2, 2012 11:13 PM
    Answerer