 |
|
 |
Hi Gustavo,
Thank you for the codes. I am running into a little problem and hoping you could help me. I really need to refresh the references for 74 projects in my solution. I am running Visual Studio 2008, however. When I run the macro, I got this error: "Unable to cast COM object of type 'System._ComObject' to interface type 'VSLangProj.VSProject'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{A SERIES OF NUMBER}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."
After getting this error, my solution was frozen. I had to end the process to get back in. In addition, I can't find System._ComObject any where else. Could you help please? Thank you very much in advance.
|
|
|
|
 |
|
 |
When I run this macro the popup is not drawing itself as it should.
On debugging the macro I found it throws an exception when it displays the PopupMessage:-
On inspection of ex you see...
- ex {System.ComponentModel.Win32Exception} System.Exception
_message "Class already exists" String
StackTrace " at System.Windows.Forms.WindowClass.RegisterClass()
at System.Windows.Forms.WindowClass..ctor(String className, Int32 classStyle)
at System.Windows.Forms.WindowClass.Create(String className, Int32 classStyle)
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at MyMacros.Module1.RefreshProjectReferences() in vsmacros://C%3A/Documents%20and%20Settings/Michael.Lang/My%20Documents/Visual%20Studio%20Projects/VSMacros/MyMacros/MyMacros.vsmacros/Module1:line 22" String
I came across this article as I was looking for a solution to a small glitch I have in a macro I'm developing which also exhibits problems when I attempt to show a form.
I'm thinking that perhaps this was ignored by everyone as the form in this example isn't that important in this macro.
Did anyone else notice that the form is not displaying correctly when running this macro ?
Thanks in advance
Michael
|
|
|
|
 |
|
 |
Michael:
You are the first that notice this error. But I has had this problem before, in other context, with a .Net control in an Web Application that uses, in the server side, a hidden Winform. I solve this problem restarting IIS . This error emerge when an application doesn't unregister a window correctly. I don't know specifically why. This error raises commonly in code that run in Runtime enviroments like macros, VBA, VSTO (Visual Studio Tools for Office), etc.
If you want more information on this error check this link:
http://www.dotnet247.com/247reference/msgs/38/190673.aspx
Here Geoff Darst of "Microsoft VSTO Tools" give an extended explantion of this error.
Best Regards.
Gustavo Bonansea
|
|
|
|
 |
|
 |
Thanks for the reply Gustavo, it looks like a very helpful link.
Opening winforms inside VSA script looks a little more difficult than you might expect.
I'll make another post if I can work out a solution.
Michael
|
|
|
|
 |
|
 |
I don't know why anybody else hasn't already complained about this but after I copy and paste your source code in Macro Explorer, assign a keystroke to it and then run the macro there is a problem when VS tries to compile the macro before running it.
You're using an undeclared variable in the main loop: i.
Just add "As Integer" to the For loop and it works like a charm,
of course !
Otherwise, great job ! Thanks.
eltwo
|
|
|
|
 |
|
 |
Dear eltwo:
Thank you very much for the observation. This code compile good some times because by default the Macro Editor code have the Option Explicit statement set in off.
Sorry for the omission. I will update the article and I will include your suggestion.
Thanks.
Gustavo
|
|
|
|
 |
|
 |
Gustavo, just an afterthought.
If you change the macro code the way I suggested you will lose backward compatibility with VS.NET 2002.
VB.NET 1.0 does not support declaring variables in a For loop as does VB.NET 1.1. So if you want to hang on to VS.NET 2002 compatibility you had better add a separate line before the For loop, declaring the integer variable i.
eltwo
|
|
|
|
 |
|
 |
eltwo:
Yes, I agree.
Thanks again.
|
|
|
|
 |
|
 |
Hi Gustavo,
Looks like great code and it's exactly what I've been looking for for quite some time ... Pardon my ignorance but I have never coded macros before so how do you use your code ???
Also, will this work for VS2002/1.0 or only VS2003/1.1 ???
Cheers.
|
|
|
|
 |
|
 |
Hi D.T.,
In order to put this code to work you need open the Macro Editor (by pressing Alt + F11 in the VS IDE). Then you can add the code to an existing file or create another one. When you decided where put your code, copy the sub and the class and paste it somewhere in the editor.
You must include this imports in the code (I apology because I omit this in the article):
Imports EnvDTE
Imports System.Diagnostics
Imports VSLangProj
Imports System
Imports System.Drawing
After that you must add a reference to "System.Drawing.dll" library in the Macros project.
You only need to save the project, look in the Macro Explorer (Alt + F8 in VS IDE) and execute the macro. If you wish, you can add a key combination for the macro execution like I describe in the article.
I don´t test it, but I suppose the code works good in VS2002 too.
Enjoy it.
If you have any question, post it here.
|
|
|
|
 |
|
 |
Hi Gustavo,
Thanks for the reply and I got it to work after your additions to the code !!
I think I missed the point of this macro though - I thought it would refresh the project's references so that if, for instance, I had developed a class library and referenced it in my solution, the macro would refresh it if I made changes to the class library project !!!
It seems to just refresh the projects within a solution and not the references within each project ... is this right or am I being incredibly naive ??
Cheers.
|
|
|
|
 |
|
 |
D.T. :
The macro iterate for the projects of a Solution and refresh the dll references of each one. So, if you have a reference to MyPrettyLibrary.dll and you was made some changes to this library, when you run the macro the new version of the Dll will be copied to the project. The macro refresh the references within each project. It works like when you press the refresh button in the references folder in all projects in the solution.
Regards.
|
|
|
|
 |
|
 |
Hi Gustavo,
Cheers for your help - I got it to work and it works just as you said !!
Keep up the good work.
|
|
|
|
 |
|
|
 |
|
 |
Don't you have another photo?
Anyway you article is very good and I am waiting the book. When it come out?
Isa
|
|
|
|
 |
|
 |
Yes, I have other pics but they are ugly like this.
About the book,... I know that the article is not a wonder, but is my first one. I promess you that the next will be better (I was preparing one about how to compile with CodeDom). If you are interested in my book, I encourage you read about Aspect Oriented Programming (AOP) and write it together.
PD: What´s ISA, it's your name?, Industry Standart Architecture?,Instrument Society of America?, Internet Server Application? International Smalltalk Association?, Internation Security Affairs? Instruction Set Architecture?, Idle Speed Actuator?, etc.
PD2:Do you know that Isa in Sanskrit language is the Supreme Lord? Paradoxical, doesn't?
|
|
|
|
 |
|
 |
I think that you were keeping this joke for a long time waiting for the opportunity of use it. Besides, it is obvious that you don´t have any important thing to do to lose time in this joke that I consider a lack of respect. I will be waiting for your excuse.
Sincerely, Incredible and Sensacional Argentinian (ISA)
|
|
|
|
 |
|
 |
I sorry for disappoint you, but I don't prepare my jokes. All that information was created in real-time like the images in my messenger. If you believe that I can't improvise you don't know me. You may visit the site of the ISA (International Stuttering Association)
|
|
|
|
 |
|
 |
are u a relative of chikito ??
MCP Bruno Capuano
Jefe de Desarrollo
PECTRA Technology Inc.
All the Solutions in One Product
+54(351)4245756 - int. 301
www.pectra.com
|
|
|
|
 |
|
 |
Dear Bruno:
No, I'm not. But be sure that your ñora know him.
|
|
|
|
 |