I am fairly new to writing in VB and in reality it is actually my first true language that I am trying to learn. I am currently writing a small application for where I work that will be used internally by only a couple of people. The purpose of this project is to record and maintain records for troubleshooting calls. This is in essence a CYA (cover your *ss) ploy that also helps us maintain with compliance rules. So essentially what I did was create a small program that would refernce back to a database out on one of our servers. This was supposed to be something that I assumed would be very easy, and at first it did seem to be working properly. Now I have run into a problem that I do not have a solution for. The following is the error I get when I begin to debug.
Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
It is my understanding that this error is telling me that permission to the datasource has been denied. However, I do not understand how exactly to fix this
If anyone has any idea's as to how I could correct this error please let me know.
Also, if you think that I am going to way to much work for this little teenie project also let me know that.
Thanks,
LR
Error Message that I can't resolve...
Vishva
I guess I don't know the answer to either of your question's really. The reason I am using the older ODBC data provider is because that is the way I know how to do it. If you can provide to me a better way to do I would appreciate that.
As to the second question, I don't really know what happens in InitConnection. Sorry I know I am being a pain, but like I said I am new to VB. In reality I am just new to programming.
LR
tonhinbm
iGNiTe
And, yes, next time I will copy the stacktrace over in order to help you help me.
Thanks for all your help.
LR
j3ns3n
Mark the question as resolved and give me my brownie points for answering please! hehe.
On the serious note security is a concern in developing applications and .NET is no different.
While the short term solution would be to run this application locally if your project requirements are that you have to run this from a network share then you should familiarize yourself with CAS and change your local policy to elevate applications running from that share but ONLY as much as needed.
Beyond that though, try to develop your application under least-privilege (NON ADMIN account - NO write-access to Program Files). If you don't use your application in the environment your end users will then a whole bucket of errors like this are gonna pop up when the user gets it. I know it's a hastle but better to change your frame of mind than to take the easy way out and avoid all patterns and practices of security awareness or ship a product that only works right on your machine.
Just my $0.02
gofrm
<System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Friend Property Connection() As System.Data.OleDb.OleDbConnection
Get
If (Me._connection Is Nothing) Then
Me.InitConnection
End If
Return Me._connection
End Get
Set
Me._connection = value
If (Not (Me.Adapter.InsertCommand) Is Nothing) Then
Me.Adapter.InsertCommand.Connection = value
End If
If (Not (Me.Adapter.DeleteCommand) Is Nothing) Then
Me.Adapter.DeleteCommand.Connection = value
End If
If (Not (Me.Adapter.UpdateCommand) Is Nothing) Then
Me.Adapter.UpdateCommand.Connection = value
End If
Dim i As Integer = 0
Do While (i < Me.CommandCollection.Length)
If (Not (Me.CommandCollection(i)) Is Nothing) Then
CType(Me.CommandCollection(i),System.Data.OleDb.OleDbCommand).Connection = value
End If
i = (i + 1)
Loop
End Set
End Property
ishkmi
I would think you might be running this application from a network share or url.
The "error message" deals with the .NET Code Access Security model. The runtime grants or denies certain functionality to code based on evidence about it. Code ran from the intranet (Not local computer) is less trustworthy so the framework doesn't give it permissions to run amok about your file system. Code running from an internet address is even less trustworthy.
In the future, when you get an exception copy the StackTrace property of the exception - this should allow us to better identify the offending line (though I don't think anything is wrong with the line in this case)
Alvin Kuiper
Hi,
I suspect that error is occurring because you need to digitally sign your solution with a strong name. Right click a project, and select signing...
http://msdn2.microsoft.com/en-us/library/ms247123.aspx
Dat Dang
Dwarf44