none
That assembly does not allow partially trusted callers (for a newbie) RRS feed

  • Question

  • With my sincere apologies for my naivety, I wonder if I can ask for some help.

     

    I have used VB6 and am (slowly) making the transition to VB 2008. With VB6, I could store my code on a mapped drive without an issue.

     

    My code snippet is as below: (I have added a reference to the Excel libray using Project >> Add Reference)

     

    --------------------------------------------------------

    Imports System.Data

    Imports System.Data.SqlClient

    Imports Excel = Microsoft.Office.Interop.Excel

     

    Public Class Form1

    Dim xlApp As Excel.Application 'Excel Application Object

    Dim xlBook As Excel.Workbook 'Excel Workbook Object

    Dim xlSheet As Excel.Worksheet 'Excel Spreadsheet Object

     

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    xlApp = New Excel.Application 'Create an application object

    xlApp.Visible = True

     

    End Sub

    End Class

    --------------------------------------------------------

     

    Obviously all that  the program does in open Excel which I will then use to generate some excel reports.

     

    This works fine if I store the project on my local PC but when I store the code on a mapped drive, I am getting the 'That assembly does not allow partially trusted callers.' message. I assume this is because of the reference to Excel and the fact that the project is stored on a mapped drive.

     

    I have had a good search through many forums but regret that the solutions are beyond my knowledge.

     

    Is anyone able to please explain what the message means in very simple terms that I might understand?

     

    In addition, can anyone possibly let me know how I resolve this issue please?

     

    Many thanks for your consideration.

     

    Thursday, April 3, 2008 4:54 PM

Answers

  • It is exactly as you described.  Since the project is stored on a map drive and it is trying to access libraries over the internet/intranet there is a security restriction in place to prevent that.  You can read more about it here: Using Libraries from Partially Trusted Code

    Essentially you will need to run your project local to Excel because you have no way to enable AllowPartiallyTrustedCallers on that assembly.
    Thursday, April 3, 2008 7:57 PM

All replies

  • It is exactly as you described.  Since the project is stored on a map drive and it is trying to access libraries over the internet/intranet there is a security restriction in place to prevent that.  You can read more about it here: Using Libraries from Partially Trusted Code

    Essentially you will need to run your project local to Excel because you have no way to enable AllowPartiallyTrustedCallers on that assembly.
    Thursday, April 3, 2008 7:57 PM
  • Thanks inetscan, that's very helpful.

     

    Another quick question - the mapped drive in this instance is simply a Windows server on our network. If Excel was installed ON that server (not sure if it is or not), would the error message disappear?

     

    Thanks.

     

    Friday, April 4, 2008 4:46 AM