Visual Basic.net Security on a Network Drive

B

Brian

I have a vb.net application which runs fine when
installed locally on a user machine but when the
application is run from a network drive a security
exception error occurs. I've set the intranet zone
through the .Net Configuration wizard to Full Trust and
the app still has a security exception. I've turned on
Just in Time Debugging and noticed the security exception
is happening at that below line of code.

Dim rs As New ADODB.Recordset()

Any help would be greatly appreciated.
 
C

Cor

Hi Brian,
Dim rs As New ADODB.Recordset()

I can not believe it is this line of code, but nearby this line of code is
probably a line of code from the database that has to be connected, is that
not the error?

Just a thought
Cor
 
B

Brian

Dim rs As New ADODB.Recordset()
Dim strSQL As String
Dim strGroup As String
Dim tn As TreeViewEX.TreeNode
Dim rClickedNode As TreeViewEX.TreeNode = _
TreeViewEX1.GetNodeAt
(TreeViewEX1.PointToClient(Cursor.Position))

Try
lblVersion.Text =
Application.ProductVersion.ToString
'imgMDIMainForm.Width = gWidth
'imgMDIMainForm.Height = gHeight
SetConnection()
gWellInfo = False

rs = CreateObject("ADODB.Recordset")

The above is a piece of the coding. I set the connection
using a module called SetConnection(). The error is at
the Dim statement. If I comment out the Dim it will run
until it gets to the SetConnection called in which it
errors with a security exception. Anything dealing with
a call to ado I get the security exception. If I comment
out everything dealing with a ado call to the database
the app will run.
 
C

Cor

Hi Brian,
If you had 5 lines of code more we could see more.
But do you have in the catch something as
Catch sqlEx As SqlException
MessageBox.Show(sqlEx.ToString, "", MessageBoxButtons.OK,
MessageBoxIcon.Error)
and
Catch ex As Exception
frmStatusMessage.Close()
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK,
MessageBoxIcon.Error)

than you can maybe see than better what is the error.

You never know if you find it this way.
Cor
 
B

Brian

It's erroring before the try and catch. I move the try
above and still get the error on the same line. Here is
a look of how the coding is.

Private Sub frmMainMenu_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Try
Dim rs As New ADODB.Recordset()
Dim strSQL As String
Dim strGroup As String
Dim tn As TreeViewEX.TreeNode
Dim rClickedNode As TreeViewEX.TreeNode = _
TreeViewEX1.GetNodeAt
(TreeViewEX1.PointToClient(Cursor.Position))

lblVersion.Text =
Application.ProductVersion.ToString
SetConnection()
gWellInfo = False

rs = CreateObject("ADODB.Recordset")

...

rs.Open(strSQL, gConnection,
ADODB.CursorTypeEnum.adOpenForwardOnly)
...
rs.Close()

...
rs.Open(strSQL, gConnection,
ADODB.CursorTypeEnum.adOpenForwardOnly)
...
rs.Close()

...
rs.Open(strSQL, gConnection,
ADODB.CursorTypeEnum.adOpenForwardOnly)
If Not rs.EOF Then
gGroup = "m4Admins"
End If
rs.Close()

...

rs.Open(strSQL, gConnection,
ADODB.CursorTypeEnum.adOpenForwardOnly)
...
rs.Close()
rs = Nothing
Catch sqlEx As SqlException
MessageBox.Show(sqlEx.ToString, "",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
 
C

Cor

Brian,
If you put that normal catch before or after the catch from the sql, than
maybe you can see what happens,
Then maybe you can see the reason why there is an exception that is not a
SQL exception.
That it is at the end is not important, it is in the Try mechanism.

rs = Nothing
Catch sqlEx As SqlException
MessageBox.Show(sqlEx.ToString, "",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Catch ex As Exception
frmStatusMessage.Close()
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub

Cor
 
B

Brian

Thanks for the help. The solution was with the version
of MDAC. If you don't mind I have another problem that's
happening since the ADO part is fixed. Below is another
security issue I'm have when executing the application
from a network drive

An unhandled exception of
type 'System.Security.SecurityException' occurred in
system.windows.forms.dll

Additional information: Security error.

The line of code where it errors out at follows:

Private Sub frmMain_Load(ByVal sender As Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Dim frmMainMenu As New frmMainMenu()
'Try
gForm = Me
frmMainMenu.MdiParent = Me
frmMainMenu.Show() <----THIS IS WHERE THE ERROR IS
'Catch Ex As Exception
' MessageBox.Show(Ex.Message, "",
MessageBoxButtons.OK, MessageBoxIcon.Error)
'End Try
End Sub
 
C

Cor

Brian,

I think that for Mdi forms Armin know the answers without even that he has
to think 2 seconds.
(and maybe from the netwerk problem too)
I only can go searching this newsgroup, filter the not so good answers for
you and give you the best.
But probably Armin knows this direct. (mostly he is here about 22-23GMT)
My advice.
Make a total new message.
And give the text it the subject "problem with showing MDI form"
Armin opens that always.
Success,
Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top