473,385 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

StrongNameIdentityPermissionAttribute invalid cast

Hi !

I have built an Add-in for VS.NET 2003 which adds or updates the
StrongNameIdentityPermissionAttribute in all the classes of the selected
project in a solution. When the classes don't have the attribute, is is
added fine, but in the code that updates the attribute, I am having a slight
problem, since when I try to cast the read attribute to a
StrongNameIdentityPermissionAttribute it throws an invalid cast exception.
Can someone help me ? The below code is where the error occurs:
If CurrentClass.Attributes.Count > 0 Then
'-- For the current class, see if the attribute
StrongNameIdentityPermissionAttribute exists and act accordingly
For Each CurrentAttribute As CodeAttribute In CurrentClass.Attributes
'-- If the attribute already exists, change it to the new public key
If CurrentAttribute.Name.IndexOf("StrongNameIdentityP ermission")
<> -1 Then
Dim NewAttribute As
System.Security.Permissions.StrongNameIdentityPerm issionAttribute
'-- *** ERROR occurs in line below ***
NewAttribute = CType(CurrentAttribute,
System.Security.Permissions.StrongNameIdentityPerm issionAttribute)
NewAttribute.Action =
Security.Permissions.SecurityAction.LinkDemand
NewAttribute.PublicKey = Key
CurrentAttribute = NewAttribute
Log.Write("Updated public key in class: " & CurrentClass.Name,
NewKey.DTE.Solution.FullName & ".log")
AttFound = True
End If
Next
End If

--

*****************************************
Mário Sobral

www.MarioSobral.com
www.CBRWorld.net
www.PerformanceTotal.com
*****************************************
Nov 20 '05 #1
0 803

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

Similar topics

0
by: Alan Z. Scharf | last post by:
Win Server 2003 VS.Net 2003 --------------- 1. I'm having the same problem below on all six of my pages with a datagrid item. 2. These pages all worked fine for months until problem started....
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
3
by: John Howard | last post by:
Making the following call to a local MSAccess database works fine: Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) Dim intRows As Integer Dim strSQL As String Dim ds As New...
1
by: Hifni Shahzard | last post by:
Hi, I got a stored procedure, where it returns a value. But if I execute it. It gives an error as "Invalid cast from System.Int32 to System.Byte.". To make clear how do I execute this, below I'm...
15
by: David | last post by:
Hi, I have built a web application that will be a very high profile application. We had tested it, demonstrated it and shown that it all works. On a dress rehearsal run through, it failed...
1
by: Mythran | last post by:
I have the following setup: BLL Project Category.vb AssemblyInfo.vb Schema Project Category.xsd AssemblyInfo.vb
1
by: Nelson | last post by:
Hi Folks, How can I secure an Assembly (DLL) from being referenced in programs other than my Strong Named Assembly (EXE) by using the StrongNameIdentityPermissionAttribute. Nelson
7
by: chance | last post by:
Getting and error on this first line of code: //inspector phone theField = reader.GetString(20); builder.MoveToBookmark("inspector_phone"); builder.Write(theField); the first line is...
5
by: =?utf-8?b?QXNiasO4cm4gU8OmYsO4?= | last post by:
For various reasons, I have a number of typedefs to name arrays of various sizes and for various purposes. I also have functions taking variables of such typedef-ed types as their input arguments....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.