using custom assembly in procedure RRS feed

  • Question

  • Hi.

    I'm trying to use custom c# in a proc but doesn't seem to be supported.

    Have tired the code behind and using a registered assembly. The REFERENCE doesn't seem to be supported syntax in a proc so the script within can't see the C# class and function. If I use code behind it just doesn't seem to work when I call the proc. The error says the function doesn't exist. This seems to be quite a limitation unless I'm doing something wrong?

    My C# code is valid, unit tested and works if I execute as a script.

    Thanks in advance.


    Sunday, November 13, 2016 11:40 AM

All replies

  • Fixed my own issue - should REFERENCE ASSEMBLY. So will re-phrase the question.

    So it works if register the assembly. However the code behind doesn't work seems you have to register the assembly to use it inside a database procedure. Do others concur?

    Thanks :)


    Sunday, November 13, 2016 11:54 AM
  • Hi Shaun,

    As you can read here under - U-SQL and Visual Studio’s Code-Behind Capabilities – is that when using code-behind files actually also CREATE/REFERENCE ASSEMBLY statements will be generated and executed and at the end a DROP ASSEMBLY statement.

    I start all my SP CREATE statements with:






        USE DATABASE [Database];

        REFERENCE ASSEMBLY [MyAssembly];

    Jorg Klein's Microsoft Business Intelligence Blog

    Tuesday, November 15, 2016 10:00 AM
  • Thanks for response.

    Yeah that's what I understood that it doesn't the work for you behind.

    This wasn't working for my proc though but I guess your saying I have to put the reference in regardless i.e. doesn't do that bit for me.

    My concern was that it on does the dynamic compile of the assembly on the code behind when I run the code to actually create the procedure and not when the procedure is called. So kind of implies to me that code behind is not an option for stored procs. Will try with the reference in and see what happens.



    Wednesday, November 23, 2016 12:56 PM