+ Reply to Thread
Results 1 to 3 of 3

Error calling Web Service from Excel Application

  1. #1
    GPrabaka
    Guest

    Error calling Web Service from Excel Application

    Please find code below which is run by an Excel macro. I am trying to make
    this call a Webservice I wrote in another C# solution.

    When the code trys to run this method, it gives the error "Execution
    permission cannot be acquired". Even the MsgBox At the Top does not appear.
    However, if I comment the line token = new usernameToken(..., The MsgBox Came
    to the End will appear.

    Does anyone know what is the problem.

    Thanks
    Guha
    PS. This application
    Imports Office = Microsoft.Office.Core (Microsoft Office 11.0 Object Library)
    Imports Excel = Microsoft.Office.Interop.Excel (Microsoft Excel 11.0 Object
    Library)
    <<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>
    Public Sub PostToSwims(ByVal publisherName As String, _
    ByVal vendorName As String, _
    ByVal programName As String, _
    ByVal effectiveDate As String, _
    ByVal jobDesc As String, _
    ByVal fileName As String)
    MsgBox("At the top")
    Dim strResult As String
    Dim token As UsernameToken
    Dim username As String = "BLAHBLAH"
    Dim passwordBytes() As Byte = System.Text.Encoding.UTF8.GetBytes("BSBSBS")
    Array.Reverse(passwordBytes)
    Dim passwordEquivalent As String

    passwordEquivalent = Convert.ToBase64String(passwordBytes)
    token = Nothing

    Try
    token = New UsernameToken(username, passwordEquivalent,
    PasswordOption.SendPlainText)
    Catch ex As Exception
    MsgBox(ex.Message)
    End Try

    MsgBox("Came to the End")

    End Sub

  2. #2
    Thanapol R.
    Guest

    RE: Error calling Web Service from Excel Application

    I've got this error too. I tried to trust all assemblies that my Excel
    program used, but it didn't work.

    This is an error I got;

    System.Security.Policy.PolicyException: Execution permission cannot be
    acquired.

    at System.Reflection.Assembly.nLoad(AssemblyName fileName, String
    codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean
    throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)

    at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef,
    Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)

    at System.Reflection.Assembly.Load(AssemblyName assemblyRef, Evidence
    assemblySecurity)

    at System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly()

    at System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly()

    at
    eYesoft.Tools.WebServices.DynamicWebServiceProxy.BuildAssemblyFromWsdl(String
    strWsdl)

    at eYesoft.Tools.WebServices.DynamicWebServiceProxy.BuildProxy()

    at eYesoft.Tools.WebServices.DynamicWebServiceProxy..ctor(String
    wsdlLocation, String inTypeName, String inMethodName)

    at UCI.Client.UCIApplication.AsyncInvokeService(UCIServiceTask task)

    at VaRExcel.OfficeCodeBehind.CalculateRequest(String brokerUrl, Int32
    numWorker, Int32 numRequest, String date, Int32 method) in
    c:\inetpub\wwwroot\hpcnc\uciclientexample\varexcel\thisworkbook.cs:line 220

    at VaRExcel.OfficeCodeBehind.ThisApplication_SheetFollowHyperlink(Object
    sh, Hyperlink target) in
    c:\inetpub\wwwroot\hpcnc\uciclientexample\varexcel\thisworkbook.cs:line 188

    Please help.
    Thanks
    Thanapol R.

  3. #3
    GPrabaka
    Guest

    RE: Error calling Web Service from Excel Application

    I am sorry, no one else responded to my post with any suggestions. So I had
    to try an alternate solution.

    "Thanapol R." wrote:

    > I've got this error too. I tried to trust all assemblies that my Excel
    > program used, but it didn't work.
    >
    > This is an error I got;
    >
    > System.Security.Policy.PolicyException: Execution permission cannot be
    > acquired.
    >
    > at System.Reflection.Assembly.nLoad(AssemblyName fileName, String
    > codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean
    > throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)
    >
    > at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef,
    > Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
    >
    > at System.Reflection.Assembly.Load(AssemblyName assemblyRef, Evidence
    > assemblySecurity)
    >
    > at System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly()
    >
    > at System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly()
    >
    > at
    > eYesoft.Tools.WebServices.DynamicWebServiceProxy.BuildAssemblyFromWsdl(String
    > strWsdl)
    >
    > at eYesoft.Tools.WebServices.DynamicWebServiceProxy.BuildProxy()
    >
    > at eYesoft.Tools.WebServices.DynamicWebServiceProxy..ctor(String
    > wsdlLocation, String inTypeName, String inMethodName)
    >
    > at UCI.Client.UCIApplication.AsyncInvokeService(UCIServiceTask task)
    >
    > at VaRExcel.OfficeCodeBehind.CalculateRequest(String brokerUrl, Int32
    > numWorker, Int32 numRequest, String date, Int32 method) in
    > c:\inetpub\wwwroot\hpcnc\uciclientexample\varexcel\thisworkbook.cs:line 220
    >
    > at VaRExcel.OfficeCodeBehind.ThisApplication_SheetFollowHyperlink(Object
    > sh, Hyperlink target) in
    > c:\inetpub\wwwroot\hpcnc\uciclientexample\varexcel\thisworkbook.cs:line 188
    >
    > Please help.
    > Thanks
    > Thanapol R.


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1