JavaScript permissions.securitypermission fejl
Jeg har lavet flg. kode i VB.Net#############################
Public Class myControl
Inherits System.Windows.Forms.UserControl
Private strUserName As String
Public ReadOnly Property UserName() As [String]
Get
strUserName = GetUserName()
Return strUserName
End Get
End Property
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'UserControl overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'
'myControl
'
Me.Name = "myControl"
Me.Size = New System.Drawing.Size(8, 8)
End Sub
#End Region
Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, _
ByRef nSize As Integer) As Integer
Public Function GetUserName() As String
Dim iReturn As Integer
Dim userName As String
userName = New String(CChar(" "), 50)
iReturn = GetUserName(userName, 50)
GetUserName = userName.Substring(0, userName.IndexOf(Chr(0)))
End Function
End Class
#############################
Selve dll'en kalder jeg fra en HTML side med flg. kode:
#############################
<html>
<body color=white>
<hr>
<font face=arial size=1>
<OBJECT id="myControl1" name="myControl1" classid="fstLogin.dll#fstLogin.myControl" width=1 height=1>
</OBJECT>
</font>
<form name="frm" id="frm">
<input type=button value="Click me" onClick="doScript();">
</form>
<hr>
</body>
<script language="javascript">
function doScript()
{
alert(myControl1.UserName);
}
</script>
</html>
#############################
Når jeg aktiverer knappen på siden får jeg denne JavaScript fejl:
System.Security.Permissions.SecurityPermission
Jeg har trusted det site jeg kører siden på.
Er der nogle restriktioner i VB.Net som gør at jeg ikke kan trække bruger data ud med min dll, og vil en VB6 ActiveX alternativt kunne gøre det?
MVH Erik