Error: System.UriFormatException: Invalid URI: The URI is empty.
-
Friday, December 16, 2011 7:53 AM
Hi
I am able to load the assmeblies in SQL Server. However, when I execute my SQL Server function that loads the assmebly, I get this error below.
Please do note that we have a DLL "nsoftware.inpay" and our wrapper DLL works perfectly as a .NET application but only when it is loaded into SQL Server as an assembly it gives me this error, I am making a reference to nsoftware.inpay dll, and when I take out the line of code that instatiated a new instance of nsoftware.inpay.icharge, it works fine.
Please help as this is very urgent!
Error:
System.UriFormatException: Invalid URI: The URI is empty. at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) at System.Uri..ctor(String uriString) at System.ComponentModel.Design.RuntimeLicenseContext.GetLocalPath(String fileName) at System.ComponentModel.Design.RuntimeLicenseContext.GetSavedLicenseKey(Type type, Assembly resourceAssembly) at nsoftware.InPay.IchargeExtraValues.GetLicense(LicenseContext context, Type type, Object instance, Boolean allowExceptions) at System.ComponentModel.LicenseManager.ValidateInternalRecursive(LicenseContext context, Type type, Object instance, Boolean allowExceptions, License& license, String& licenseKey) at System.ComponentModel.LicenseManager.ValidateInternal(Type type, Object instance, Boolean allowExceptions, License& license) at System.ComponentModel.LicenseManager.Validate(Type type, Object instance) at nsoftware.InPay.Icharge..ctor(IContainer container, String rtk) at nsoftware.InPay.Icharge..ctor() at ePayment_CC_Assembly.EPI_CC..ctor() at ePayment_CC_Assembly.EPI_Payment_CC_Assembly.SubmitCCPayment(Object obj, Int32& Paymentresult, String& ConfirmationNo, String& FailureMessage, String& InternalErrMsg)
All Replies
-
Friday, December 16, 2011 8:33 AMModeratorI'm not sure from your description what you are doing inside the SQL function that causes the error. If you are trying to load an external assembly (i.e. one that's not already cataloged to SQL Server with CREATE ASSEMBLY) into SQL Server in your SQL function code, this will work in a .NET program but will not work in a SQLCLR function. SQL Server only allows loading of assemblies that already exist in the database's catalog, not from outside, for security reasons. If this is not what you're doing, you need to provide more information, for example the code that fails. Cheers, Bob
-
Friday, December 16, 2011 11:48 AMHiithis is my wrapper dll class libraray code:<SqlFunction(FillRowMethodName:="SubmitCCPayment", systemdataaccess:=SystemDataAccessKind.Read, DataAccess:=DataAccessKind.Read)> _Public Shared Function ProcessCCPayment(ByVal SQLClientConnectionString As String, ByVal PaymentProcessor As Integer, ByVal AccountNo As Integer, ByVal SubAccountNumber As String, ByVal Amount As Double, _ByVal CCNo As String, ByVal ExpMonth As String, ByVal ExpYr As String, _ByVal CSCode As String, ByVal Address1 As String, ByVal City As String, ByVal State As String, ByVal ZipCode As String, ByVal InterfaceOpt As Integer, _ByVal ClientIPAddress As String, ByVal IsAutoPay As String, _ByVal InvoiceNo As String, ByVal RunSequence As String, ByVal TransactionType As Integer, _ByVal CCHardHolderName As String, Optional ByVal COMMENT1 As String = "", Optional ByVal COMMENT2 As String = "", _Optional ByVal INsertToPayment As Boolean = True, Optional ByVal IsDeposit As Boolean = False, Optional ByVal TransId As String = "") As IEnumerableDim Paymentdt As New DataTablePaymentdt.Columns.Add("ConnectionString", GetType(String))Paymentdt.Columns.Add("PaymentProcessor", GetType(Integer))Paymentdt.Columns.Add("AccountNo", GetType(Long))Paymentdt.Columns.Add("SubAccountNumber", GetType(String))Paymentdt.Columns.Add("Amount", GetType(Double))Paymentdt.Columns.Add("CCNo", GetType(String))Paymentdt.Columns.Add("CCHolderName", GetType(String))Paymentdt.Columns.Add("ExpMonth", GetType(String))Paymentdt.Columns.Add("ExpYr", GetType(String))Paymentdt.Columns.Add("CSCode", GetType(String))Paymentdt.Columns.Add("Address1", GetType(String))Paymentdt.Columns.Add("City", GetType(String))Paymentdt.Columns.Add("State", GetType(String))Paymentdt.Columns.Add("ZipCode", GetType(String))Paymentdt.Columns.Add("InterfaceOpt", GetType(Integer))Paymentdt.Columns.Add("ClientIPAddress", GetType(String))Paymentdt.Columns.Add("IsAutoPay", GetType(Integer))Paymentdt.Columns.Add("InvoiceNo", GetType(String))Paymentdt.Columns.Add("RunSequence", GetType(String))Paymentdt.Columns.Add("TransactionType", GetType(Integer))Paymentdt.Columns.Add("COMMENT1", GetType(String))Paymentdt.Columns.Add("COMMENT2", GetType(String))Paymentdt.Columns.Add("INsertToPayment", GetType(Boolean))Paymentdt.Columns.Add("IsDeposit", GetType(Boolean))Paymentdt.Columns.Add("TransId", GetType(String))Dim dr As DataRow = Paymentdt.NewRowdr("ConnectionString") = SQLClientConnectionStringdr("PaymentProcessor") = PaymentProcessordr("AccountNo") = AccountNodr("SubAccountNumber") = SubAccountNumberdr("Amount") = Amountdr("CCNo") = CCNodr("CCHolderName") = CCHardHolderNamedr("ExpMonth") = ExpMonthdr("ExpYr") = ExpYrdr("CSCode") = CSCodedr("Address1") = Address1dr("City") = Citydr("State") = Statedr("ZipCode") = ZipCodedr("InterfaceOpt") = InterfaceOptdr("ClientIPAddress") = ClientIPAddressdr("IsAutoPay") = IsAutoPaydr("InvoiceNo") = InvoiceNodr("RunSequence") = RunSequencedr("TransactionType") = TransactionTypedr("COMMENT1") = COMMENT1dr("COMMENT2") = COMMENT2dr("INsertToPayment") = INsertToPaymentdr("IsDeposit") = IsDepositdr("TransId") = TransIdPaymentdt.Rows.Add(dr)Return Paymentdt.RowsEnd Function<Microsoft.SqlServer.Server.SqlFunction(systemdataaccess:=SystemDataAccessKind.Read, DataAccess:=Microsoft.SqlServer.Server.DataAccessKind.Read)> _Public Shared Sub SubmitCCPayment(ByVal obj As Object, <Out()> ByRef Paymentresult As Integer, <Out()> ByRef ConfirmationNo As String, <Out()> ByRef FailureMessage As String, <Out()> ByRef InternalErrMsg As String)'Public Shared Sub SubmitCCPayment(ByVal obj As DataRow, <Out()> ByRef Paymentresult As Integer, <Out()> ByRef ConfirmationNo As String, <Out()> ByRef FailureMessage As String, <Out()> ByRef InternalErrMsg As String)TryDim PaymentProcessor As IntegerDim Amount As Double'Dim sqlcon As SqlConnection = NothingDim COnnectionString As String = ""Dim TransactionType As IntegerDim Paydr As DataRow = DirectCast(obj, DataRow)'PaymentProcessor = obj.gatewayid'Amount = obj.TransactionAmount'COnnectionString = obj.connectionstring'TransactionType = obj.transtypePaymentProcessor = eutils.Nz(Paydr("PaymentProcessor"), 0)Amount = eutils.Nz(Paydr("Amount"), 0)COnnectionString = eutils.Nz(Paydr("ConnectionString"), "")TransactionType = eutils.Nz(Paydr("TransactionType"), 0)If PaymentProcessor = 0 ThenPaymentresult = 2ConfirmationNo = 0FailureMessage = "Invalid payment processor."InternalErrMsg = ""'resultdr = PopulateRsltRow(resultDt, Paymentresult, ConfirmationNo, FailureMessage, InternalErrMsg)'resultDt.Rows.Add(resultdr)'Return resultDt.Rows'Exit TryEnd IfIf TransactionType = 0 ThenPaymentresult = 2ConfirmationNo = 0FailureMessage = "Invalid transaction method."InternalErrMsg = ""Exit TryEnd If'If Amount <= 0 Then' Paymentresult = 2' ConfirmationNo = 0' FailureMessage = "Invalid payment amount."' InternalErrMsg = ""' 'resultdr = PopulateRsltRow(resultDt, Paymentresult, ConfirmationNo, FailureMessage, InternalErrMsg)' 'resultDt.Rows.Add(resultdr)' 'Return resultDt.Rows' Exit Try'End If'If PaymentProcessor = 1 ThenDim epi As New EPI_CC // This EPI_CC is a public class included in Code library, here i amgetting an Error when creating the instance of EPI_CC'Dim icharge As New nsoftware.InPay.Icharge ////This is a dll included in Code library, here i amgetting an Error when creating the instance of Icharge'icharge.Gateway = 1InternalErrMsg = epi.CCpaymentresult(TransactionType, Paydr, COnnectionString, ConfirmationNo, InternalErrMsg)' Paymentresult = 1 ' Authorize_CC_Lib.ProcessCCPayment(Paydr, COnnectionString, ConfirmationNo, FailureMessage, InternalErrMsg)' Else' FailureMessage = "Processor Not Found"' End IfCatch excp As ExceptionConfirmationNo = "0"FailureMessage = excp.ToString() '.Message.ToString()InternalErrMsg = ""Paymentresult = 2Finally'If Not IsNothing(sqlcon) Then' If sqlcon.State <> ConnectionState.Closed Then' sqlcon.Close()' End If' sqlcon = Nothing'End IfEnd TryEnd Sub******************************Table valued Function is:Create FUNCTION [ePayment].[EPI_Submit_CC_Payment_Using_Assembly](@SQLClientConnString [nvarchar](255), @PaymentProcessor [int], @account_no [int], @sub_account_no [nvarchar](50), @amount [float], @ccno [nvarchar](20), @expMonth [nvarchar](2), @expYear [nvarchar](4), @pnlCode [nvarchar](10), @Address1 [nvarchar](250), @city [nvarchar](50), @state [nvarchar](10), @ZipCode [nvarchar](10), @InterfaceOpt [int], @IPAddress [nvarchar](50), @IsAutoPay [nvarchar](50), @InvoiceNo [nvarchar](50), @RunSequence [nvarchar](50), @TransactionMethod [int], @CCHardHolderName [nvarchar](50), @Comment1 [nvarchar](250), @Comment2 [nvarchar](250), @inserttoPayment [bit], @is_deposit [bit], @TransId [nvarchar](50))RETURNS TABLE ([Paymentresult] [int] NULL,[ConfNumber] [nvarchar](50) NULL,[ErrMsg] [nvarchar](4000) NULL,[InternalErrMsg] [nvarchar](500) NULL) WITH EXECUTE AS CALLERASEXTERNAL NAME [ePayment_CC_Assembly].[ePayment_CC_Assembly.EPI_Payment_CC_Assembly].[ProcessCCPayment]Please help me as soon as possible.ThanksAnkit
- Edited by Ankit_MCL Friday, December 16, 2011 11:49 AM
-
Friday, December 16, 2011 6:16 PMModeratorHi Ankit,The error that you are getting is “System.UriFormatException: Invalid URI: The URI is empty”, but I don’t see anything in your .NET code that passes the URI in or initializes it at all. Does your called component expect to find a URI somewhere (like a config file)? If so, you can try putting it in sqlserver.exe.config, subject to the limitation that, while this works now, using a config file with SQLCLR is not guaranteed to work in future.But by looking at the error message (but not the code that produces it), I can’t figure out when the called component expects to find its URI.Hope this helps,Cheers,Bob
-
Monday, December 19, 2011 7:29 AM
Hi Bob,
Thanks a lot for your response.
Here nsoftware.Inpay is a third party dll, when we are creating any instance of the class used in that Dll in our Wrapper dll, there it creates the Error. When i told them regarding that, they told me to download the Licence file and include it in the bin folder . I did the same but that Error not Removed.
Please help me asap
Thanks
Ankit
-
Tuesday, June 12, 2012 11:30 AM
Hi, it is a long time. I think, that I have exactly the same problem with some else third party library. It is licensed by licx file too. Inside SQL Server CLR procedure it crash with System.UriFormatException ...
Did you solve it somehow?

