472,354 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

'System.Security.SecurityException' with .NET 2005 Only

microsoft.public.dotnet.languages.vb.upgrade isn't getting much
traffic, so I'll try here.

Ours is a VB6 shop exploring .NET.
First I wrote a new application with VB .NET 2003 to create a pdf
Crystal Report from a SQL Server 2000 table. I followed advice from
the MSDN article "Add Professional Quality Reports to Your Application
with Visual Studio .NET"
(http://msdn.microsoft.com/msdnmag/is...2/05/Crystal/), and it
worked fine.
Then we got in VB .NET 2005, and I tried to open this solution
there, with the idea of deploying it as our first .NET server app in a
few days. The Wizard seemed to take it from 2003 to 2005 with no
problem, and I get a clean build. However, when I run, I can't connect

to the test SQL Server I've been using even though I am an
administrator.
Here's the code:
Friend WithEvents scnSQLConnection As _
System.Data.SqlClient.SqlConnection
Friend WithEvents sdaDataAdapter As _
System.Data.SqlClient.SqlDataAdapter
Friend WithEvents ndsMain As MySolutionName.MyDatasetClassName
.. . .
Public Sub FrmThatHasCrystalViewer_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
scnSQLConnection.ConnectionString = _
"Persist Security Info=False;Integrated Security=SSPI;database=" & _

"MyDatabase;server=OurTestSQLServer2000"
sdaDataAdapter.Fill(ndsMain)
It fails on the line above and, in the immediate window, I get:
A first chance exception of type 'System.Security.SecurityException'
occurred in System.Data.dll
When I click on view detail, I get:
System.Security.SecurityException was unhandled
Message="Request for the permission of type
'System.Data.SqlClient.SqlClientPermission,
System.Data, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed."
Source="mscorlib" . . .
The dialog box suggests clicking on "Add Permission to the Project." I

did that, and get a dialog box saying "The new permission has been
added to your application. However, the change will not take effect
until the debugging session is restarted."
Restart the debugging session, same problem again. Go all the way of
VS and back in again, still same problem. Reboot, same problem.
I could deploy the VS 2003 build, but it would be nicer startingt off
with a consistent current version inventory, not to mention that I
would like to understand more.
All ideas and suggestions will be appreciated.
Steve Eisenberg

Apr 9 '06 #1
3 10331
Please show how you are initializaing the variablles and the sql text.

Does the same sql text work from Query Analyzer under the same user
credentials?

<st********@yahoo.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
microsoft.public.dotnet.languages.vb.upgrade isn't getting much
traffic, so I'll try here.

Ours is a VB6 shop exploring .NET.
First I wrote a new application with VB .NET 2003 to create a pdf
Crystal Report from a SQL Server 2000 table. I followed advice from
the MSDN article "Add Professional Quality Reports to Your Application
with Visual Studio .NET"
(http://msdn.microsoft.com/msdnmag/is...2/05/Crystal/), and it
worked fine.
Then we got in VB .NET 2005, and I tried to open this solution
there, with the idea of deploying it as our first .NET server app in a
few days. The Wizard seemed to take it from 2003 to 2005 with no
problem, and I get a clean build. However, when I run, I can't connect

to the test SQL Server I've been using even though I am an
administrator.
Here's the code:
Friend WithEvents scnSQLConnection As _
System.Data.SqlClient.SqlConnection
Friend WithEvents sdaDataAdapter As _
System.Data.SqlClient.SqlDataAdapter
Friend WithEvents ndsMain As MySolutionName.MyDatasetClassName
. . .
Public Sub FrmThatHasCrystalViewer_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
scnSQLConnection.ConnectionString = _
"Persist Security Info=False;Integrated Security=SSPI;database=" & _

"MyDatabase;server=OurTestSQLServer2000"
sdaDataAdapter.Fill(ndsMain)
It fails on the line above and, in the immediate window, I get:
A first chance exception of type 'System.Security.SecurityException'
occurred in System.Data.dll
When I click on view detail, I get:
System.Security.SecurityException was unhandled
Message="Request for the permission of type
'System.Data.SqlClient.SqlClientPermission,
System.Data, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed."
Source="mscorlib" . . .
The dialog box suggests clicking on "Add Permission to the Project." I

did that, and get a dialog box saying "The new permission has been
added to your application. However, the change will not take effect
until the debugging session is restarted."
Restart the debugging session, same problem again. Go all the way of
VS and back in again, still same problem. Reboot, same problem.
I could deploy the VS 2003 build, but it would be nicer startingt off
with a consistent current version inventory, not to mention that I
would like to understand more.
All ideas and suggestions will be appreciated.
Steve Eisenberg

Apr 9 '06 #2
This is most likely caused by your project residing in an old folder that
doesn't have the necessary .Net security permissions. When you open the
project you may have received an error message stating something about
unsafe location. Also, this would happen if you save your project to a
network folder that is not a part of the .Net security framework. I can't
recall everything to be exact but the quickest way to test to see if this is
the case is to save your project to the project folder the initial VB.net
installation has created for you and run it from there. Read more about the
..Net Configuration tool to setup your security for a networked folder.

<st********@yahoo.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
microsoft.public.dotnet.languages.vb.upgrade isn't getting much
traffic, so I'll try here.

Ours is a VB6 shop exploring .NET.
First I wrote a new application with VB .NET 2003 to create a pdf
Crystal Report from a SQL Server 2000 table. I followed advice from
the MSDN article "Add Professional Quality Reports to Your Application
with Visual Studio .NET"
(http://msdn.microsoft.com/msdnmag/is...2/05/Crystal/), and it
worked fine.
Then we got in VB .NET 2005, and I tried to open this solution
there, with the idea of deploying it as our first .NET server app in a
few days. The Wizard seemed to take it from 2003 to 2005 with no
problem, and I get a clean build. However, when I run, I can't connect

to the test SQL Server I've been using even though I am an
administrator.
Here's the code:
Friend WithEvents scnSQLConnection As _
System.Data.SqlClient.SqlConnection
Friend WithEvents sdaDataAdapter As _
System.Data.SqlClient.SqlDataAdapter
Friend WithEvents ndsMain As MySolutionName.MyDatasetClassName
. . .
Public Sub FrmThatHasCrystalViewer_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
scnSQLConnection.ConnectionString = _
"Persist Security Info=False;Integrated Security=SSPI;database=" & _

"MyDatabase;server=OurTestSQLServer2000"
sdaDataAdapter.Fill(ndsMain)
It fails on the line above and, in the immediate window, I get:
A first chance exception of type 'System.Security.SecurityException'
occurred in System.Data.dll
When I click on view detail, I get:
System.Security.SecurityException was unhandled
Message="Request for the permission of type
'System.Data.SqlClient.SqlClientPermission,
System.Data, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed."
Source="mscorlib" . . .
The dialog box suggests clicking on "Add Permission to the Project." I

did that, and get a dialog box saying "The new permission has been
added to your application. However, the change will not take effect
until the debugging session is restarted."
Restart the debugging session, same problem again. Go all the way of
VS and back in again, still same problem. Reboot, same problem.
I could deploy the VS 2003 build, but it would be nicer startingt off
with a consistent current version inventory, not to mention that I
would like to understand more.
All ideas and suggestions will be appreciated.
Steve Eisenberg

Apr 9 '06 #3
+Vice wrote:
This is most likely caused by your project residing in an old folder
that doesn't have the necessary .Net security permissions.


Yep. Just the kind of error a newbie might and did make.

Usenet still rocks for this kind of stuff.

Thanks to +Vice for the solution and Jim Hughes, who probably would
have gotten me there also.

Apr 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James B | last post by:
OMA (Outlook Mobile Access) under Exchange is giving me a System.Security.SecurityException error. From what I gather this is a problem with the security level under which the OMA application is...
2
by: MFRASER | last post by:
I am getting a System.Security.SecurityException when I try and laod a dataset from an xml file any ideas on what would cause this? System.Security.SecurityException' occurred in mscorlib.dll ...
0
by: Seok Bee | last post by:
Dear Experts, I've created a Console application to perform a checking of an Excel file. During development using vb.net in Visual Studio 2005, the application is running fine. I can get my...
3
by: Carl | last post by:
Hi. I have my program written as a console application in C# .NET 2005. I run it from a server on the local intranet and I got this message: An unhandled exception of type...
1
by: eisenb | last post by:
microsoft.public.dotnet.languages.vb.upgrade isn't getting much traffic, so I'll try here. Ours is a VB6 shop exploring .NET. First I wrote a new application with VB .NET 2003 to create a pdf...
4
by: stephen | last post by:
Hi, I am getting an error while trying to create an excel file. "Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the...
0
by: Siberwulf | last post by:
I'm trying to fetch an XML document from a website through an assembly i built and attached to SQL 2005. Here is my code for the SPROC assembly: public static void fetch_FeedData(string...
3
by: Mike | last post by:
Hi I have problem as folow: Caught Exception: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Request for the permission of type...
5
by: Henry Stock | last post by:
I am trying to understand the following error: Any thing you can tell me about this is appreciated. Security Exception Description: The application attempted to perform an operation not allowed...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.