Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Thursday, December 17, 2009

"Missing XML comment..." in service reference file

When I added service reference in my project I have got a lot of "Missing XML comment for public visible type..." warning messages in Reference.cs file. Those warnings didn't allow me to see real important warning messages. To disable this, add:


#pragma warning disable 1591


at the beginning of Reference.cs file and


#pragma warning restore 1591


at the end of Resource.cs file.

And off course you will need to add this every time you update reference.

Monday, November 30, 2009

Unable to find service IVsDiscoveryService

I had a problem with Visual Studio 2008. When I try to update service reference I have got following error message: "Unable to find service IVsDiscoveryService"...

To solve this do the following:
Open command prompt, go to the devenv folder (usually C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE) ande type following command:

devenv /resetskippkgs


You can save some time for finding visual studio disk and reinstalling visual studio.

Friday, July 24, 2009

Remote debugging and c#

You are trying to set remote debugging on remote computer that is in domain. You search internet and set everything it's write there.
  • Add the same user with the same password to the remote computer and add it to administrators group.
  • You setup firewall correctly (or even turn of firewall)
  • You set local security policy as it is described to MSDN
But when you try to connect you get something like: "Debugger on target computer cannot connect back to this..." and "Authentication failed."

In this case you should try to:
  • Turn of UAC
  • Run msvsmon.exe as user on local machine using command prompt and runas command (runas /user:localuser msvsmon.exe)
(localuser must have admin privileges on remote computer)

Enjoy in remote debugging.

Thursday, January 08, 2009

Resharper, Stylecop and type members layout

In order to resort type members layout to match requirements of StyleCop using ReSharper open ReSharper's settings, choose "Type Members Layout" and paste following XML:


<Patterns xmlns="urn:shemas-jetbrains-com:member-reordering-patterns">


 


  <!--Do not reorder COM interfaces-->


  <Pattern>


    <Match>


      <And Weight="100">


        <Kind Is="interface"/>


        <HasAttribute CLRName="System.Runtime.InteropServices.InterfaceTypeAttribute"/>


      </And>


    </Match>


  </Pattern>


 


  <!--Special formatting of NUnit test fixture-->


  <Pattern RemoveAllRegions="true">


    <Match>


      <And Weight="100">


        <Kind Is="class"/>


        <HasAttribute CLRName="NUnit.Framework.TestFixtureAttribute" Inherit="true"/>


      </And>


    </Match>


 


    <!--Setup/Teardow-->


    <Entry>


      <Match>


        <And>


          <Kind Is="method"/>


          <Or>


            <HasAttribute CLRName="NUnit.Framework.SetUpAttribute" Inherit="true"/>


            <HasAttribute CLRName="NUnit.Framework.TearDownAttribute" Inherit="true"/>


            <HasAttribute CLRName="NUnit.Framework.FixtureSetUpAttribute" Inherit="true"/>


            <HasAttribute CLRName="NUnit.Framework.FixtureTearDownAttribute" Inherit="true"/>


          </Or>


        </And>


      </Match>


    </Entry>


 


    <!--All other members-->


    <Entry/>


 


    <!--Test methods-->


    <Entry>


      <Match>


        <And Weight="100">


          <Kind Is="method"/>


          <HasAttribute CLRName="NUnit.Framework.TestAttribute" Inherit="false"/>


        </And>


      </Match>


      <Sort>


        <Name/>


      </Sort>


    </Entry>


  </Pattern>


 


  <!--Default pattern-->


  <Pattern RemoveAllRegions="true">


 


    <!--Delegates-->


    <Entry>


      <Match>


        <And Weight="100">


          <Access Is="public"/>


          <Kind Is="delegate"/>


        </And>


      </Match>


      <Sort>


        <Access Order="public internal protected-internal protected private" />


        <Name/>


      </Sort>


    </Entry>


 


    <!--Fields and constants-->


    <Entry>


      <Match>


        <Or>


          <Kind Is="field"/>


          <Kind Is="constant"/>


        </Or>


      </Match>


      <Sort>


        <Access Order="public internal protected-internal protected private" />


        <Kind Order="constant"/>


        <Readonly/>


        <Static/>


        <Name/>


      </Sort>


    </Entry>


 


    <!--Enums-->


    <Entry>


      <Match>


        <Kind Is="enum"/>


      </Match>


      <Sort>


        <Access Order="public internal protected-internal protected private" />


        <Name/>


      </Sort>


    </Entry>


 


    <!--Constructors. Place static one first-->


    <Entry>


      <Match>


        <Kind Is="constructor"/>


      </Match>


      <Sort>


        <Static/>


        <Access Order="public internal protected-internal protected private" />


      </Sort>


    </Entry>


 


    <!--Destructors. Place static one first-->


    <Entry>


      <Match>


        <Kind Is="destructor"/>


      </Match>


      <Sort>


        <Static/>


        <Access Order="public internal protected-internal protected private" />


      </Sort>


    </Entry>


 


    <!-- Events -->


    <Entry>


      <Match>


        <Kind Is="event"/>


      </Match>


      <Sort>


        <Access Order="public internal protected-internal protected private" />


        <Name/>


      </Sort>


    </Entry>


 


    <!--Properties-->


    <Entry>


      <Match>


        <And>


          <Kind Is="property"/>


          <Not>


            <Kind Is="indexer"/>


          </Not>


        </And>


      </Match>


      <Sort>


        <Access Order="public internal protected-internal protected private" />


        <Static/>


        <Abstract/>


        <Virtual/>


        <Override/>


        <Name/>


      </Sort>


    </Entry>


 


    <!--Indexers-->


    <Entry>


      <Match>


        <Kind Is="indexer"/>


      </Match>


      <Sort>


        <Access Order="public internal protected-internal protected private" />


        <Static/>


        <Abstract/>


        <Virtual/>


        <Override/>


        <Name/>


      </Sort>


    </Entry>


 


    <!--Methods-->


    <Entry>


      <Match>


        <And>


          <Or>


            <Kind Is="method"/>


            <Kind Is="operator"/>


            <HandlesEvent />


          </Or>


          <Not>


            <Kind Is="destructor"/>


          </Not>


        </And>


      </Match>


      <Sort>


        <Access Order="public internal protected-internal protected private" />


        <Static/>


        <Abstract/>


        <Virtual/>


        <Override/>


        <Name/>


      </Sort>


    </Entry>


 


    <!--all other members-->


    <Entry/>


 


    <!--nested types-->


    <Entry>


      <Match>


        <Kind Is="type"/>


      </Match>


      <Sort>


        <Access Order="public internal protected-internal protected private" />


        <Static/>


        <Abstract/>


        <Virtual/>


        <Override/>


        <Name/>


      </Sort>


    </Entry>


  </Pattern>




Now, choose Cleanup Code.

( tnx to Jordan Dimitrov)

Monday, December 29, 2008

Add file header

To add C# file header according to StyleCop's SA1633 you can use this macro:



Sub AddFileHeader()


        DTE.ActiveDocument.Selection.StartOfDocument()


        DTE.ActiveDocument.Selection.Text = "//-----------------------------------------------------------------------"


        DTE.ActiveDocument.Selection.NewLine()


        DTE.ActiveDocument.Selection.Text = "// <copyright file=""" + DTE.ActiveDocument.Name() + """ company=""MyCompany d.o.o."">"


        DTE.ActiveDocument.Selection.NewLine()


        DTE.ActiveDocument.Selection.Text = "//    Copyright (c) MyCompany d.o.o. All rights reserved."


        DTE.ActiveDocument.Selection.NewLine()


        DTE.ActiveDocument.Selection.Text = "// </copyright>"


        DTE.ActiveDocument.Selection.NewLine()


        DTE.ActiveDocument.Selection.Text = "//-----------------------------------------------------------------------"


        DTE.ActiveDocument.Selection.NewLine(2)


    End Sub


Friday, December 26, 2008

Visual Studio - Create Blank Solution

If you want first to create blank solution in Visual Studio on specific location and then to add existing projects or create new one you will be very disappoint if you expect to find "Create Blank Solution" item under the New menu.
To create blank solution do the following:
  1. On the File menu, select New and then click Project.

  2. In the Project types pane, select Other Project Types and then select Visual Studio Solutions.

  3. In the Templates pane, select Blank Solution.

Wednesday, November 26, 2008

Remove tabs and spaces from end of line

If you are frustrated when you press "End" key and cursor goes much behind your last character, you can use this macro to remove all spaces and tabs from end of the line:





Sub RemoveTabsAndSpacesFromEnd()
DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr
DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
DTE.Find.FindWhat = ":b+{\n}"
DTE.Find.ReplaceWith = "\1"
DTE.Find.Target = vsFindTarget.vsFindTargetFiles
DTE.Find.MatchCase = True
DTE.Find.MatchWholeWord = False
DTE.Find.MatchInHiddenText = True
DTE.Find.SearchPath = "Current Document"
DTE.Find.SearchSubfolders = True
DTE.Find.KeepModifiedDocumentsOpen = False
DTE.Find.FilesOfType = ""
DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResults1
DTE.Find.Execute()
End Sub





Now, just assign some keyboard shortcut to this macro.

Wednesday, November 05, 2008

Debug inside .net framework source code

To enable debugging inside .net framework source code follow instructions on this page:
http://referencesource.microsoft.com/serversetup.aspx

(For symbol location enter: http://msdl.microsoft.com/download/symbols)

Saturday, October 25, 2008

.NET Disassembler

You can download here free disassembler. This disassembler does not have export functions. To enable export function you can download plugin here.

Thursday, October 23, 2008

Accessing object anywhere in code

If you want to see some object wherever in code (in watch window) do the following:
  • Set breakpoint in a place where you create this object
  • Right mouse button and "Add Watch"
  • In Watch window, right mouse button on your object and select "Make Object ID"
  • You will see something like {1#}. 1# is your object ID
  • Now, wherever you break your code you can add in watch window 1# and you will see your object

Friday, October 10, 2008

Test run pending trouble

Sometimes when I start unit test from visual studio all test are in pending phase and no test will run.
Open task manager find proses named as VSTestHost.exe and kill it. After that try to start tests again.
It works for me.

And here is macro to do that for you



Sub KillDeadTestProcess()
Dim objProcess As System.Diagnostics.Process
For Each objProcess In System.Diagnostics.Process.GetProcesses()
Debug.Print(objProcess.ProcessName)
If (objProcess.ProcessName = "VSTestHost") Then
objProcess.Kill()
End If
Next
End Sub

Monday, July 21, 2008

Remote Debugging

Sometimes you need to debug application on remote machine. To do that you need to copy files for remote debugging on to remote machine. You can find those files in:

c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger


Run msvsmon.exe on remote machine and set security.

In Visual Studio, in project settings, go to Configuration Properties Debugging, chose Remote Windows Debugger (from Debugger to launch), set other parameters and press F5.
If you have set all correctly, application on remote machine will be started.

Friday, June 27, 2008

Locate current opened file in solution explorer

To locate current opened file in solution explorer you can use this macro:


Sub LocateInSolutionExplorer()
DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")
DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")
End Sub

Monday, June 16, 2008

Add custom library or form in Visual Studio Macros

  1. Create custom class library in language that you prefer.
  2. In Build events Post build events add: copy "$(TargetPath)" "$(DevEnvDir)PublicAssemblies\"
  3. In macro from where you whant to use your custom library add reference to your class library
  4. You are now free to use your custom library in your macro

Tuesday, June 10, 2008

Find commented peace of code

In the process of re factoring of your code you may wish to delete commented peaces of code. You can use this regular expression to find potential trash in your code

((//.*\n)(//.*\n)+)(\/\*(.\n)#\*\/)

Friday, May 16, 2008

Force debugger to stop when some variable change value

Sometimes is very useful to know when value of some variable is changed. To force debugger to stop when it happens run debugger to place from where you want to monitor your variable (Variable must be instanced because you need to know it's address).

In Breakpoints window chose NewNew data breakpoint.
Now, fill breakpoint parameters and next time when your variable is changed, anywhere in code, debugger will stop.

Tuesday, April 22, 2008

Sourcesafe and "An Error Occurred in the Secure Channel Support" message

I tried to enable VSS on IIS. Installation pass correctly but when I try to connect SourceSafe I was getting this error message “An Error Occurred in the Secure Channel Support”. I tried everything but with no results. And finally I found that the problem was that some process didn’t have permission on Windows\temp folder.

Useful links:
http://alinconstantin.dtdns.net/WebDocs/SCC/VSS_Internet.htm

Useful tools (if you have any problem to enable VSS on Internet:
Filddler:
http://www.fiddler2.com/

Monday, April 21, 2008

Visual studio 2005 toolbox icons screwed up

Right click on toolbox and select "Reset toolbox" from context menu to get icons back