473,326 Members | 2,114 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,326 software developers and data experts.

Add-In works on C# project, not on VB.NET project

Hi !

I have written an Add-In to use in VS.NET 2003.

The Add-In asks the user for a public key on a small form,
and then
basically goes through a selected project, looking for
public classes,
and when finds one, it checks if the attribute
StrongNameIdentityPermissionAttribute exists.

If so, it should update it to a new public key specified
before. If
not, it should create the attribute.

I am developing this add-in in VB.NET (don't ask, current
company
policies... I usually code in C#!). When I apply the add-
in to a C#
project, it works fine. When I applied it to a VB.NET
project, it
fails. After some searching and head scratching, I found
out that the
AddAttribute function of the CodeClass is not implemented
for VB.NET
:-(. So I went and tried it by "hand", by writing the
attribute
string. Doesn't work either, showing the following error:

Error processing CodeItem: ExceptionsLog --> class being
processed at
the time of the error
Error in ProcessElem[ExceptionsLog]: Not implemented

By stepping through the code, the exception occurs on the
following
line:

ed = CurrentClass.GetStartPoint.CreateEditPoint
This is the method where it all goes wrong:

-----------------------------------------------------------
--------------
Private Shared Sub ProcessElem(ByVal Elem As CodeElement,
ByVal
AttributeName As String, ByVal Key As String, ByVal
Language As
ProjectLanguage)
'-- If already found a class element,
insert/update attribute
Dim CurrentClass As CodeClass = CType(Elem,
CodeClass)
If CurrentClass.Access.vsCMAccessPublic Then
Dim AttFound As Boolean = False
Try
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 =
AttributeName Then
Dim NewAttribute As
System.Security.Permissions.StrongNameIdentityPerm issionAtt
ribute
NewAttribute = CType
(CurrentAttribute,
System.Security.Permissions.StrongNameIdentityPerm issionAtt
ribute)
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
'-- If no
StrongNameIdentityPermissionAttribute was
found, create one and add it to the class
If Not AttFound Then
'-- According to MS, the AddAttribute
function is
not implemented yet for VB.NET
'Dim NewAttribute As
System.Security.Permissions.StrongNameIdentityPerm issionAtt
ribute
'NewAttribute =
CurrentClass.AddAttribute
("StrongNameIdentityPermissionAttribute", "")
'NewAttribute.Action =
Security.Permissions.SecurityAction.LinkDemand
'NewAttribute.PublicKey = Key
Dim ed As EditPoint
'-------- ERROR HAPPENS ON THE NEXT LINE ---------------
ed =
CurrentClass.GetStartPoint.CreateEditPoint
If Language = ProjectLanguage.VBNET
Then
ed.Insert("<" & AttributeName &
"(SecurityAction.LinkDemand, PublicKey := "" & Key & "")>
_" & vbCrLf)
ElseIf Language.CSHARP Then
ed.Insert("[" & AttributeName &
"(SecurityAction.LinkDemand, PublicKey = """ & Key
& """)] " & vbCrLf)
End If
Log.Write("Added public key to
class: " &
CurrentClass.Name, NewKey.DTE.Solution.FullName & ".log")
End If
Catch ex As Exception
Dim Message As String = "Error in
ProcessElem[" &
Elem.Name & "]: "
Throw New Exception(Message & ex.Message)
End Try
End If
End Sub
-----------------------------------------------------------
--------------

Thanks in advance for any help !
Mario Sobral

Nov 15 '05 #1
0 828

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

Similar topics

5
by: Mike L | last post by:
I have two questions. 1) What is the code to check if datagrid already has a datasource? When the user clicks "ADD" button I want to add a record to the data grid, if the user clicks "ADD"...
3
by: Dean Slindee | last post by:
Is there a way to replace the commented out parameter add syntax with a single line of code, like the .Parameter.Add("@Letter"...) line below (which does not work)? 'Dim prmLetter As New...
4
by: Maarten | last post by:
i have the folowing code to setup my datagrid collumns Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load gridsetup() end sub
8
by: Yuk Tang | last post by:
I am tearing my hair out over this, since I can't see what I'm doing wrong (duh, if I knew, I wouldn't be asking the question). I am adding Field items to a Field Collection, but for some reason...
0
by: herman404 | last post by:
Hi everyone, I'm trying to dynamically add 3 button columns to a DataGrid object that I have on an ASP.net webpage, but I don't see any documentation on how to do it. I've seen plenty of examples...
3
by: Greg Scharlemann | last post by:
I'm not sure the best way to accomplish this... my hunch is with javascript, but I'm not sure if using server side code (PHP) would be easier. I'm adding people to a database. People have a...
1
by: Sri Nanduri | last post by:
Hi , I am new to JS. Please help me to resolve my issue. 1.When the form loads there are two DropDown boxes and a ADD button. 2.When I click the add button it will add two DropDown boxes and a add...
0
by: anureddy | last post by:
help me how to add datagridview columns to another table,using windowsapplications. and set the displaymember and value member datagridviewcomboboxcolumn. i used this below code but that not...
0
acoder
by: acoder | last post by:
Problem The select object's add method doesn't append options to the end of the list. Browser Internet Explorer Example The Javascript code for appending an option element at the end of a...
2
by: Question123 | last post by:
<root> <Element> <add key="1" value="1"/> <add key="2" value="2"/> <add key="3" value="3"/> <add key="4" value="4"/> </Element> <Items>
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.