473,385 Members | 1,542 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.

Add In does not work on VB.NET project but does on C#

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 20 '05 #1
4 1281
Mario,

You need to pass a Constant in the GetStartPoint function. Look at the vsCMPart
constants in the help to find out what part you need.

Your code should look like the following:

CurrentClass.GetStartPoint(vsCMPart.vsCMPartAttrib utes).CreateEditPoint()
Hope this helps!
Bharat Patel
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks.

Nov 20 '05 #2
Bharat,

THanks for your reply, I was only able to go back to this project now.
I have tried your recommendation, using the following code:

(...)
Dim ed As EditPoint
ed = CurrentClass.GetStartPoint(vsCMPart.vsCMPartAttrib utes).CreateEditPoint
(...)
But it still gives me the "Not implemented" error :-(

I haven't been able to solve this problem, and it's so strange to have
errors such as these. Something done in VB.NET, when applied to C#
project works, but when applied to VB.NET project doesn't work :-S

Mario Sobral


bh*****@online.microsoft.com (Bharat Patel [MSFT]) wrote in message news:<gu**************@cpmsftngxa07.phx.gbl>...
Mario,

You need to pass a Constant in the GetStartPoint function. Look at the vsCMPart
constants in the help to find out what part you need.

Your code should look like the following:

CurrentClass.GetStartPoint(vsCMPart.vsCMPartAttrib utes).CreateEditPoint()
Hope this helps!
Bharat Patel
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks.

Nov 20 '05 #3
Hi Mario,

I checked Object Browser for CodeClass interface and did not see GetStartPoint
method or property.
You can try StartPoint property of CodeClass and then call CreateEditPoint.

I am sure you already have the reference to EnvDTE.dll in your project. So if
you open the Object Browser, you will see all the properties and methods of the
CodeClass.
Go through it and you will figure out what to do.

Hope this helps!
Bharat Patel
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks.

Nov 20 '05 #4
Yes, I did that and it worked, thanks !!!!!!!! What a simple solution
for such a problem :-)

Nevertheless, the GetStartPoint shows in Intelissense as well as the
StartPoint property.

I now have another small prblem, but I'll post it separatly.

Thanks again for your time and the helpful suggestions, Bharat.

Mario Sobral


bh*****@online.microsoft.com (Bharat Patel [MSFT]) wrote in message news:<SP**************@cpmsftngxa07.phx.gbl>...
Hi Mario,

I checked Object Browser for CodeClass interface and did not see GetStartPoint
method or property.
You can try StartPoint property of CodeClass and then call CreateEditPoint.

I am sure you already have the reference to EnvDTE.dll in your project. So if
you open the Object Browser, you will see all the properties and methods of the
CodeClass.
Go through it and you will figure out what to do.

Hope this helps!
Bharat Patel
Microsoft, Visual Basic .NET

Nov 20 '05 #5

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

Similar topics

7
by: Jonas | last post by:
This works fine in Win XP but does not work at all in Win 98. Private WithEvents objIExplorer As InternetExplorer I have to do it like this to get it to work in Win 98 Dim objIExplorer As...
14
by: Dave Murray | last post by:
New to Python question, why does this fail? Thanks, Dave ---testcase.py--- import sys, urllib, htmllib def Checkit(URL): try: print "Opening", URL
6
by: Ariel | last post by:
I have an application that works correctly in debug mode but it does not work in release. I am not using anything of the class system.diagnostics. I tried to disable the optimization code, but...
1
by: Wendy Elizabeth | last post by:
Can you give me some suggestions of why the xml web service is not working? I have an xml web service that works in my visual studio. net 1.1 environment. I setup this project up for deployment...
5
by: tindog | last post by:
I seem to be caught in a bit of a conundrum with C#. First of all getting books on VS 2003.net then VS 2005 comes out and further a book I have bought to just learn just the language C# (in 21...
1
by: Wendy Elizabeth | last post by:
Can you give me some suggestions of why the xml web service is not working? I have an xml web service that works in my visual studio. net 1.1 environment. I setup this project up for deployment...
14
by: Anoop | last post by:
Hi, I am new to this newsgroup and need help in the following questions. 1. I am workin' on a GUI application. Does C# provides Layout Managers the way Java does to design GUI? I know that it...
3
by: Mark Leistner | last post by:
I am having problems getting a gridview to bind to custom objects under any non-full trust level. I created a test project to verify what I am seeing isn't a side effect of other code in my...
3
by: Nick Gilbert | last post by:
Hi, In my VS.NET 2005, if I choose Build Clean Solution, the BIN folder is not touched. Shouldn't it delete all the dll and pdb files in that folder first? Instead, I'm finding I have to do it...
4
by: Jason Teagle | last post by:
I'm not sure which is the correct group to post this to, if either, so apologies for the crosspost and if it's OT. I have a Visual Studio.NET 2002-compiled solution that originated at work. At...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.